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

3 ビュー (過去 30 日間)
janani subraveti
janani subraveti 2017 年 7 月 4 日
コメント済み: Denis Gurchenkov 2017 年 7 月 14 日
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 Center および File ExchangeIntroduction 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