Scattered data interpolation simulink
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Christopher Dadswell
am 15 Feb. 2018
Hi Joel,
Did you find a solution to this? Currently having a similar issue.
many thanks, Chris
Antworten (1)
yang xiang
am 5 Mär. 2019
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 Kommentare
Dave Hall
am 27 Jul. 2022
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
am 27 Jul. 2022
Ah, nevermind. I wasn't using the interpreted matlab function block. Now it works.
Siehe auch
Kategorien
Mehr zu Array and Matrix Mathematics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!