Creating matrix with incremental values
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sariha Azad
am 2 Jun. 2019
Bearbeitet: KALYAN ACHARJYA
am 2 Jun. 2019
How can I create a matrix like
A=[1 2 3;4 5 6;7 8 9]
using loops?
0 Kommentare
Akzeptierte Antwort
KALYAN ACHARJYA
am 2 Jun. 2019
Bearbeitet: KALYAN ACHARJYA
am 2 Jun. 2019
using loops, you asked for.
mat1=[];
row_num=3; % Change the row number as per require
colm_num=3; % Change the col number as per require
count=0;
for i=1:row_num
for j=1:colm_num
count=count+1;
mat1(i,j)=count;
end
end
disp(mat1);
0 Kommentare
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!