필터 지우기
필터 지우기

Interpolating a whole matrix

조회 수: 2 (최근 30일)
Inmodi
Inmodi 2014년 12월 19일
댓글: Mohammad Abouali 2014년 12월 19일
I have a (3x3)-matrix whose elements change with time. I store the time in a (n x 1)-array and the matrix in a (n x 3 x 3)-matrix. Now for a Simulink simulation I want to extract the (3 x 3)-matrix through interpolation by the simulation time.
Of course, in principle, I could just create interpolation tables for each element of the (3x3)-matrix and reassemble the outputs to a new (3x3)-matrix but I wonder if there'd be a simpler way.
N. B.: I don't have particular toolboxes.
  댓글 수: 1
dpb
dpb 2014년 12월 19일
...I could just create interpolation tables for each element of the (3x3)-matrix and reassemble the outputs...
If you were to instead store the array as nine columns by length N then interp1 will do each column automagically and since it's a single time slice (I presume) being returned each time a reshape to 3x3 if need shouldn't be too costly.

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

채택된 답변

Mohammad Abouali
Mohammad Abouali 2014년 12월 19일
% Making a sample data set
A(1,:,:)=ones(3,3);
A(2,:,:)=ones(3,3)*2;
A(3,:,:)=ones(3,3)*3;
time=0.1:0.1:0.3;
% now interpolating to t=0.15
B=mat2cell(A,3,ones(3,1),ones(3,1));
A_interpolated=cellfun(@(x) interp1(time,x,0.15),B);
  댓글 수: 1
Mohammad Abouali
Mohammad Abouali 2014년 12월 19일
I have not worked with simulink. Sorry that I can not help you with Simulink.

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by