Scattered data interpolation simulink

14 visualizaciones (últimos 30 días)
Joel Lapointe
Joel Lapointe el 19 de En. de 2018
Comentada: Dave Hall el 27 de Jul. de 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 comentario
Christopher Dadswell
Christopher Dadswell el 15 de Feb. de 2018
Hi Joel,
Did you find a solution to this? Currently having a similar issue.
many thanks, Chris

Iniciar sesión para comentar.

Respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Array and Matrix Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by