Matlab 如何编写代码来打印n接受矩阵的顺序?
如何在Matlab中编写此代码:Matlab 如何编写代码来打印n接受矩阵的顺序?,matlab,matrix,Matlab,Matrix,如何在Matlab中编写此代码: printf("\nEnter the order m x n of the sparse matrix\n"); scanf("%d%d",&m,&n); 谁能帮助我如何在Matlab中转换这段代码 在matlab中,我将printf写成disp('输入矩阵的顺序') 如何打印值? 我希望在运行时得到这个printf输出。我该怎么做? 实际上,我正在Matlab中编写一个代码,以接受所有矩阵顺序M*N,如下所示: enter the ord
printf("\nEnter the order m x n of the sparse matrix\n");
scanf("%d%d",&m,&n);
谁能帮助我如何在Matlab中转换这段代码
在matlab中,我将printf
写成disp('输入矩阵的顺序')代码>
如何打印值?
我希望在运行时得到这个printf
输出。我该怎么做?
实际上,我正在Matlab中编写一个代码,以接受所有矩阵顺序M*N
,如下所示:
enter the order of the matrix
2*3
然后分配一个2*3
矩阵。然后我输入值。请仔细检查!使用适当的语言和格式。当你希望别人花时间帮助你时,要有礼貌地把你的时间花在这个问题上。谢谢!但是当我输入元素时,如果~ischar(S)| ndims(S)>2,我会在32处得到一个错误==>str2num
disp('Enter the order of the m x n of the sparse matrix');
m=input('Enter m: ');
n=input('Enter n: ');
disp([num2str(m),'*',num2str(n)]);
% Enter No.of Rows
m = input('Enter number of rows: ');
% Enter No.of Rows
n = input('Enter number of columns: ');
% Iterate over rows
for i = 1:m
% Iterate over columns
for j = 1:n
% Accept an Element and convert it into number format
a(i,j) =str2num(input('Enter Element :'));
end
end