フィルターのクリア

How can I used 'save()' command in matlab function block?

8 ビュー (過去 30 日間)
SyukriY
SyukriY 2016 年 12 月 9 日
コメント済み: Kerry Schutz 2020 年 11 月 13 日
Hi, everyone. I really need everyone help. I can't used 'save()' command in matlab function block. Do anyone know? and how can I change the 'save()' command in the matlab function block?
function [DayOfOvule,Dmax,CycleLength] = detection(dataB,dataA,limit,CL)
%#codegen
A = dataA;
B = dataB;
fileD = 'difference.txt';
if (A > limit) && (B < limit)
D = A - B;
save(fileD, 'D');
elseif (A > limit) && (B > limit)
%startCountDown
else
end
CycleLength = CL;
S = load(fileD, 'D');
Dmax = max(S.D);
DayOfOvule = 13;
end
end
Does matlab can hold a value? For example, I have my data in timeseries and I want to calculate the differences between each data. Then, from differences I want to find the largest value of the different.
#credit to Walter Roberson for teach me something about delay.
%
  5 件のコメント
SyukriY
SyukriY 2016 年 12 月 9 日
編集済み: SyukriY 2016 年 12 月 9 日
Note that,
I'm using MATLAB function block to code a function in simulink.
Kerry Schutz
Kerry Schutz 2020 年 11 月 13 日
You'll need to use a file I/O function that is supported for code generation. Two examples of that would be fwrite, for binary files, and fprintf, for text files.
These functions, while they work, are still not as convenient as using save due to the overhead associated with the particulars of using lower-level file I/O functions.
You might consider a different approach to saving data in your Simulink model that originates inside a MATLAB Function block. You can try outputting the data back onto a Simulink output port and then using the To File block to save the data to a .mat file. That might be cleaner in the end.
And yes, I realize this is almost 4 years after you submitted your question but I hope it helps someone out there.
Kerry

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by