i want to save all the value of variable a from all iterations into a single matrix ?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
salman hayat
am 2 Jun. 2014
Beantwortet: George Papazafeiropoulos
am 2 Jun. 2014
f=[1 3 5 7 9 11; 2 4 6 8 10 12]; b=[1 2;3 4]; [m n]=size(f); [m c]=size(b);
for k=1:n f1=f(:,k); for i=1:c b1=b(i,:); d=0; for j=1:m
d=d+(f1-(b1)'); a(j)={sum(d)} Lt=sqrt(abs((a{j}))); end end end
0 Kommentare
Akzeptierte Antwort
George Papazafeiropoulos
am 2 Jun. 2014
% initial data
f=[1 3 5 7 9 11; 2 4 6 8 10 12];
b=[1 2;3 4];
% engine
b=b';
[nn,n]=size(f);
[m,c]=size(b);
aa=1:n;
aa=aa(ones(c,1),:);
aa=aa(:)';
f=f(:,aa);
bb=(1:c)';
bb=bb(:,ones(1,n));
bb=bb(:)';
b=b(:,bb);
% results
a=cumsum(c*(f-b))'
Lt=sqrt(abs(a))
0 Kommentare
Weitere Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!