Completing elements of a matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Karanvir singh Sohal
am 1 Mär. 2021
Kommentiert: Jan
am 5 Mär. 2021
I have a matrix a
from a I have generated a new matrix b which have 2 new elements for 1 element of a
a = [2;3]
[m,n]=size(a)
for i=1:m
b=[1.5*(a(i)) 2*(a(i))]
end
I want to generate a new matrix 'c' such that it includes all the sets
expected results as
c = [2 3;2 4;3 4.5;3 6]
2 Kommentare
Akzeptierte Antwort
Karanvir singh Sohal
am 3 Mär. 2021
3 Kommentare
Jan
am 5 Mär. 2021
These lines do the same as your loop:
for j=1:mY
index=index+1;
XD(index)=X(i);
YD(index)=Y(j);
end
but more efficiently.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!