Could anyone help me how to change the values in array
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
jaah navi
am 8 Okt. 2019
Kommentiert: Adam Danz
am 8 Okt. 2019
I ma having two array
A=[1 2
3 4
5 6];
B=[1 2];
I want to change the values present in rows of A which are not equal to B in the following manner
A=[1 2;
1 2;
1 2]
Could anyone please help me on it.
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 8 Okt. 2019
Bearbeitet: Adam Danz
am 8 Okt. 2019
A=[1 2
3 4
5 6];
B=[1 2];
A = repmat(B,size(A,1),1)
or
A = B .* ones(size(A))
2 Kommentare
Adam Danz
am 8 Okt. 2019
That could be done in a loop, though it's not clear why this would be beneficial.
A=[1 2
3 4
5 6];
B=[1 2];
for i = 1:size(A,1)
A(i,:) = B;
end
Is that what you're looking for?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays 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!