user2688423
user2688423

Reputation: 107

how to convert matlab to C using MATLAB coder

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.

Upvotes: 0

Views: 618

Answers (2)

Ryan Livingston
Ryan Livingston

Reputation: 1928

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.

Upvotes: 1

ThP
ThP

Reputation: 2332

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.

Upvotes: 1

Related Questions