MATLAB file to C compiler Command changes\ Makefile from MATLAB code
2 次查看(过去 30 天)
显示 更早的评论
I am currently trying to create a MakeFile for the following code (the data.txt file is just a 166x14 matrix of numbers). The best solution I could find for this is to use the MATLAB C coder and make a MakeFile from that, however the commands 'fscanf' and 'scatter' are not supported for the compiler. Does anyone know how I should change this code to allow it to be compiled? or if there is a better way to create a MakeFile from MATLAB code? Also please excuse my poor coding ability, this is not my expertise and I am still learning more of the best practices.
function [] = Temp_Dat(~)
tec = fopen('data.txt','r');
datr=fscanf(tec,'%f')
fclose(tec);
s=1;
dat=zeros(166,14);
for y_d =1:1:166
for x_d=1:1:14
dat(y_d,x_d)= datr(s);
s=s+1;
end
end
hold on
x_ax=dat(1,1):1:dat(end,1);
y_vec = dat(:,14).';
for x=1:1:166
scatter(x_ax(x),y_vec(x),25,'r','filled')
end
end
2 个评论
Walter Roberson
2019-11-16
Are you referring to MATLAB Compiler, or MATLAB Compiler SDK, or to MATLAB Coder?
I would not expect MATLAB Coder to support scatter(), but I would expect MATLAB Compiler to support it.
回答(1 个)
Walter Roberson
2019-11-18
MATLAB Coder does not support graphics, except some of the Computer Vision routines to "draw" into arrays, and some specialized device interfaces (e.g., controlling 7 segment LCDs on Arduino)
You can use coder.ceval() to code in calls to external libraries that do graphics for you.
To be honest, the easiest way to fscanf() in MATLAB Coder is to loop doing fgetl() and then coder.ceval() sscanf()
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!