multiplication of equevalant element of three cells by a predetermined vector

조회 수: 1 (최근 30일)
Hi all; I've written a program including some cells like below:
clc; clear;
s=[ 0 10 20 30];
pr=[0.24 0.40 0.36];
f=[625 425 425; 125 125 125; 25 25 25; 125 125 125];
sm=[30 20 10 0;-10 30 20 10;-10 -10 30 20];
for n=1:10
fmin_init{n}=f;
for t=1:3
for ss=1:4
s2{t,ss}= sm,
for qq=1:3
tsd_intrpln{n,qq}=interp1(s(:),fmin_init{n}(:,qq), s2{t,ss});
end
% my problem is here >> tsd{n,ss}= Pr.* tsd_intrpln{n,:}
end
end
end
I want to multiply each element of matrix "pr" i.e. [0.24 0.40 0.36] respectively by each element of matrix "tsd_intrpln{n,1}" and its equevalant element in "tsd_intrpln{n,2}" and also "tsd_intrpln{n,3}" for example:
-the first element of "tsd_intrpln{n,1}" is multiplied by "pr(1) " . i.e. a11* 0.24
-the first element of "tsd_intrpln{n,2}" is multiplied by "pr(2) " . i.e. a'11* 0.4
-the first element of "tsd_intrpln{n,3}" is multiplied by "pr(3) " . i.e. a''11* 0.36 .
How can I do this. I look forward to reply.m

답변 (1개)

Geoff
Geoff 2012년 4월 4일
I seem to give a lot of answers that use arrayfun, and I don't want to be cliché, but it seems you need it here to pull out the element from each matrix.
tsd{n,ss} = pr .* arrayfun(@(x) tsd_intrpln{n,x}(1,1), 1:3);
  댓글 수: 1
som
som 2012년 4월 4일
Thanks, But can you give me an explanation on how to perform " arrayfun(@(x) tsd_intrpln{n,x}(1,1), 1:3);"

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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by