matrix calculation for matrix

1 visualizzazione (ultimi 30 giorni)
mehmet salihi
mehmet salihi il 9 Mag 2021
Commentato: arsenic 陈 il 10 Mag 2021
hi everyone,
i need urgent help for my code,
i have A=400x5 matrix, and B=0x5 matrix, i want to take the 10th rows(10 20 30 40 50 60) of the A matrix and equal them to the B matrix
for example , B(5,:)=A(50,:) and B(6,:)=A(60,:) goes like this.
please need help.

Risposta accettata

arsenic 陈
arsenic 陈 il 10 Mag 2021
a = zeros(400,5);
b = ones(1,5)
for i = 10:10:400
a(i,:) = b;
end
  2 Commenti
mehmet salihi
mehmet salihi il 10 Mag 2021
how is going to be the for loop when b=ones(40,5).
this is the difficulity of loop
arsenic 陈
arsenic 陈 il 10 Mag 2021
o i thoght B=0x5 matrix it turns out to be 40*5

Accedi per commentare.

Più risposte (1)

John D'Errico
John D'Errico il 10 Mag 2021
Modificato: John D'Errico il 10 Mag 2021
Simple. One line. No for loop. Nothing hard.
B = A(10:10:end,:);
  3 Commenti
mehmet salihi
mehmet salihi il 10 Mag 2021
ok, that is awesome solution. thank you very much
arsenic 陈
arsenic 陈 il 10 Mag 2021
good

Accedi per commentare.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by