Effacer les filtres
Effacer les filtres

How to index in for loop

8 vues (au cours des 30 derniers jours)
rakesh kumar
rakesh kumar le 2 Avr 2021
Commenté : rakesh kumar le 2 Avr 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]
  1 commentaire
rakesh kumar
rakesh kumar le 2 Avr 2021
x=[3;5]

Connectez-vous pour commenter.

Réponse acceptée

David Hill
David Hill le 2 Avr 2021
Modifié(e) : David Hill le 2 Avr 2021
for k=1:length(a)
c(:,:,k)=a(k)*b;%index instead of having different variables
d(:,:,k)=r-c(:,:,k)*x;
end
  1 commentaire
rakesh kumar
rakesh kumar le 2 Avr 2021
Thanks david, thanks a lot

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by