How can I convert my script into c code using matlab coder

2 vues (au cours des 30 derniers jours)
janani subraveti
janani subraveti le 4 Juil 2017
Commenté : Denis Gurchenkov le 14 Juil 2017
clc;
fileID = fopen('pet_data.dat');
OneByte = fread(fileID,[5000 1]); %first testing for first 10bytes of data
A=uint8(OneByte);
Fs=1000;
Ts=1/Fs;
B= (0:Ts:(length(A)-1)/Fs)';
C=[B A];
When I am trying to convert the above following file into c file using matlab coder it is showing an error that it is a script and doesnot start with a function .
So i tried to give lines like these
function C = read_pet
clc;
fileID = fopen('pet_data.dat');
OneByte = fread(fileID,[5000 1]); %first testing for first 10bytes of data
A=uint8(OneByte);
Fs=1000;
Ts=1/Fs;
B= (0:Ts:(length(A)-1)/Fs)';
C=[B A];
end
but it is not right and i have to take some input arguments to read_pet and i have to use this function somewhere. I am totally confused how can i convert this into a function in c code?
  1 commentaire
Denis Gurchenkov
Denis Gurchenkov le 14 Juil 2017
Hi Janani, what is the problem here? If you remove "clc;" and then generate the C code using
codegen read_pet -config:lib -report
then it just works for me (in R2017a)

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by