Scattered data interpolation simulink

14 Ansichten (letzte 30 Tage)
Joel Lapointe
Joel Lapointe am 19 Jan. 2018
Kommentiert: Dave Hall am 27 Jul. 2022
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
Christopher Dadswell am 15 Feb. 2018
Hi Joel,
Did you find a solution to this? Currently having a similar issue.
many thanks, Chris

Melden Sie sich an, um zu kommentieren.

Antworten (1)

yang xiang
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
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
Dave Hall am 27 Jul. 2022
Ah, nevermind. I wasn't using the interpreted matlab function block. Now it works.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by