How do you initialize an N*M matrix?
3,592 ビュー (過去 30 日間)
表示 古いコメント
从MATLAB的帮助,它说使用方法:
M = matrix(N, M)
but when I apply this it says that the function 'matrix' is not recognized.
Undefinedfunction 'matrix' for input arguments of type 'double'.
Errorin experimental (line 1)
M = matrix(3,3)
採用された回答
Leah
2013 年 6 月 26 日
編集済み:MathWorks Support Team
2018 年 11 月 27 日
To initialize an N-by-M matrix, use the “zeros” function. For example, create a 3-by-5 matrix of zeros:
A = zeros(3,5);
You can then later assign specific values to the elements of “A”.
3 件のコメント
israt fatema
2021 年 8 月 25 日
Can you please show me how to assign value to A after initialize the N x M matrix? For example i need to create a vector 5 x 5 and with values x = 20 35 49 64 23
その他の回答 (4 件)
Lokesh Ravindranathan
2013 年 6 月 26 日
編集済み:Lokesh Ravindranathan
2013 年 6 月 26 日
I am assuming you are trying to create an empty matrix of zeros of dimensions N*M. You can try the following instead
M = zeros(3,3)
This creates a matrix of zeros of size 3*3.
2 件のコメント
Lokesh Ravindranathan
2013 年 6 月 26 日
Oh. Thanks Isakson. I will update my answer. My MATLAB did not have symbolic Math toolbox.
Pau
2018 年 10 月 17 日
This should make the trick
M = double.empty(N,M,0);
https://uk.mathworks.com/help/matlab/ref/empty.html
0 件のコメント
参考
カテゴリ
Find more onMatrices and ArraysinHelp CenterandFile Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!