How can I convert my script into c code using matlab coder
2 views (last 30 days)
Show older comments
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 Comment
Denis Gurchenkov
on 14 Jul 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)
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!