Matrix problem n*n
显示 更早的评论
Hii, I was trying to solve this simple problem. I have to create a matrix with first n.^2 elements: example for n=3 the matrix would be
1 2 3
4 5 6
7 8 9
I have used this strategy :
n=input('order of square matrix is? ')
for i=1:n^2;
A(i)=input('numer of elements:');
end
A=reshape(A,n,n)'
at this point I don't wanna enter the number of elements manually but I need the matrix to be created as soon as I enter the order of matrix. How can I do that?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!