How to index in for loop
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
rakesh kumar
il 2 Apr 2021
Commentato: rakesh kumar
il 2 Apr 2021
I have a an array
a=[4 9 7]
A Matrix
b= [5 7;4 2];
I want to have
c1=4*b c2=9*b; c3=7*b
. I want to use c1,c2"c3' later as d1=r-c1*x; d2=r-c2*x; Where r=[4;9]; x=[3 5]
Risposta accettata
David Hill
il 2 Apr 2021
Modificato: David Hill
il 2 Apr 2021
for k=1:length(a)
c(:,:,k)=a(k)*b;%index instead of having different variables
d(:,:,k)=r-c(:,:,k)*x;
end
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!