multiplication of equevalant element of three cells by a predetermined vector
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
Geoff
am 4 Apr. 2012
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);
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!