Scattered data interpolation simulink

14 ビュー (過去 30 日間)
Joel Lapointe
Joel Lapointe 2018 年 1 月 19 日
コメント済み: Dave Hall 2022 年 7 月 27 日
Hi,
I tried to use a lookup table in a simulink project. However my data is not monotonically increasing. So it gave me errors for breakpoints. It is not very clear how to implement lookup a table for scattered data (1 dependant + 2 independant variables).
So I reverted to put a MATLAB function block to use scatteredInterpolant() in the function. It worked when I put it in a matlab script but not in a simulink MATLAB function. Here is the error for the simulink:
%code
Undefined function or variable 'scatteredInterpolant'.
Function 'MATLAB Function' (#36.1523.1572), line 34, column 15:
"scatteredInterpolant(P_ent_mod,D_ent_mod,E_s_mod)"
Launch diagnostic report.
I want to specify that scatteredInterpolant worked well in a script but not in the simulink function block
My scattered model data are 3 .txt files which I import in the workspace in 3 column variables (no time dependency).
My questions are:
- How to do a lookup table for scattered data from 3 variables (no time dependancy and not monotonically increasing)?
- How to use the scatteredInterpolant() in a simulink MATLAB function block?
- Is ther other alternative to do interpolation in simulink than lookup tables with scattered data?
Thank you very much,
Joel Lapointe
  1 件のコメント
Christopher Dadswell
Christopher Dadswell 2018 年 2 月 15 日
Hi Joel,
Did you find a solution to this? Currently having a similar issue.
many thanks, Chris

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

回答 (1 件)

yang xiang
yang xiang 2019 年 3 月 5 日
write a script like this and execute:
a=xlsread('data.xlsx');
x=a(:,1);
y=a(:,2);
z=a(:,3);
F=scatteredInterpolant(x,y,z);
save('inp.mat','F');
then mask the block in simulink and add
load('inp.mat')
in the initialization tab.
at last, use interpreted matlab function block in simulink. use matlab funtion like this:
F(u(1),u(2))
I hope this helps you.
  2 件のコメント
Dave Hall
Dave Hall 2022 年 7 月 27 日
I see the "scatteredInterpolant" "inp" in my 'inp.mat' file, and I get no errors from the initialization command in my mask, but I get the error "Undefined function or variable 'inp'". Any ideas?
Dave Hall
Dave Hall 2022 年 7 月 27 日
Ah, nevermind. I wasn't using the interpreted matlab function block. Now it works.

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

カテゴリ

Help Center および File ExchangeArray and Matrix Mathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by