Scattered data interpolation simulink

조회 수: 15 (최근 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 CenterFile Exchange에서 Array and Matrix Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by