MATLAB file to C compiler Command changes\ Makefile from MATLAB code

2 ビュー (過去 30 日間)
Alexander Dahlmann
Alexander Dahlmann 2019 年 11 月 16 日
回答済み: Walter Roberson 2019 年 11 月 18 日
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
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.
Alexander Dahlmann
Alexander Dahlmann 2019 年 11 月 18 日
I am currently looking at using MATLAB coder for this.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
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()

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by