0

I want to convert matlab code to C code using MATLAB coder, but is doesn't work well.

I tried to below matlab code .. and build using MATLAB coder

 function  example()

     recObj = audiorecorder(44100,16,1); 
     disp('Start speaking.');
     recordblocking(recObj, 5);
     disp('End of Recording.');

      play(recObj);

But there are some errors. like..

coder -build ex1.prj ??? The 'audiorecorder' class does not support code generation.

  Error in ==> example Line: 2 Column: 10
  Code generation failed: Open error report.

so, I tried to delete audiorecorder function, but it didn't work also.

I don't know What problem in these code. How do I do? Please help.

6
  • It is simply not possible to generate code for the audiorecorder, if you need an audio recorder you have to reimplement the functionallity in c. Commented Jun 28, 2014 at 17:57
  • This question seems to be related to your previous one (deploy to android). I think it's the wrong way to deploy multimedia related code from matlab to android, because you have to deal with the android api and permissions. What is your plan? Commented Jun 28, 2014 at 18:04
  • Yeah, Actually I want to use matlab code on java(deploy to android). And I find one option that convert matlab to C code and use that C code for deploying to android. But it also doesn't work well. Commented Jun 29, 2014 at 12:28
  • Yeah, Actually I want to use matlab code on java(deploy to android). And I find one option that convert matlab to C code and use that C code for deploying to android. But Now, I failed to covert matlab code to C code. Actually, the code that I wrote for recording using matlab is just example, even though I tried to covert just disp fuction [function example() disp('Start speaking.');] to C code , but it also doesn't work. How do I do ? Please help. Commented Jun 29, 2014 at 12:35
  • I think you simply chose the wrong programming language, do you really need to use matlab? Commented Jun 29, 2014 at 13:44

2 Answers 2

1

Not every MATLAB function can be converted to C code.

For a list of supported function see here.

If you wish to use MATLAB functions that are not on the list, you should write your own version in MATLAB (if possible, in your case I doubt it) or in C.

Sign up to request clarification or add additional context in comments.

Comments

1

It may not be helpful for deploying to Android, but there is the dsp.AudioRecorder System Object that supports C code generation and allows for some audio recording. The resulting code can be run on systems where MATLAB is installed.

Another option is to write your computational algorithm in MATLAB Coder compliant code and do the audio capture, user interaction and the like using Android APIs. You could then just pass the captured audio data to the generated native code for processing. I've seen a similar approach taken with image processing where the Android API was used to capture images which were then sent to C code generated with MATLAB Coder for processing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.