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

2 次查看(过去 30 天)
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 个评论
Denis Gurchenkov
Denis Gurchenkov 2017-7-14
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)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by