How to use interpolate struct data in simulink?

조회 수: 2 (최근 30일)
Anup
Anup 2023년 2월 16일
댓글: Fangjun Jiang 2023년 2월 17일
I have a struct data file in .mat format.
I can use interp2 to interpolate the data from this struct data file in matlab.
for example,
h = interp2(data.P,data.T,data.H,234e+05,317)
How to do similiar like this in simulink?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2023년 2월 16일
편집: Fangjun Jiang 2023년 2월 16일
In general, in Simulink, the "2-D Lookup Table" block can be used to do what interp2() does in MATLAB.
You need to figure out the proper size for the input arguments though. Your example certainly has problem due to un-matched size.
data.P=1:4;
data.T=1:3;
data.H=rand(3,4);
h = interp2(data.P,data.T,data.H,1.5,2.5)
h = 0.2963
data.P=rand(3,4);
data.T=rand(3,4);
h = interp2(data.P,data.T,data.H,0.5,0.5)
Error using griddedInterpolant
Grid arrays must have NDGRID structure.

Error in interp2>makegriddedinterp (line 226)
F = griddedInterpolant(varargin{:});

Error in interp2 (line 134)
F = makegriddedinterp(X, Y, V, method,extrap);
  댓글 수: 2
Anup
Anup 2023년 2월 17일
편집: Anup 2023년 2월 17일
I only need P, T, H and all the other values can be excluded. Don't these three variables have same size. If we were to consider only these three variables, could you kindly explain to me how we can perform interpretation using a lookup table? Thank you very much for your help.
I have attached the .mat file (reduced file size).
Fangjun Jiang
Fangjun Jiang 2023년 2월 17일
My example should already explain it. If you want to run
h = interp2(data.P,data.T,data.H,234e+05,317), H is 301x400, then P needs to be 1x400 and T needs to be 1x301. See doc interp2

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by