What does the following code do?

clear all
close all
clc
M=1; n=0;
while or(M~=0,length(M(:))~=1)
M=input('Enter matrix: ');
if and(M==0,length(M(:))==1)
break
end
n=n+1;
MM{n}=M;
S(n)= sum(M(:));
end
[SS,ind]= sort(S);
Mtmp=MM;
for ii=1:n
MM{ii}=Mtmp{ind(ii)};
end
celldisp(MM);

2 件のコメント

John D'Errico
John D'Errico 2022 年 12 月 26 日
Talk to the source of the code Asing what uncommented junk code does is difficult to say, especially if we are given no clue as to what it is supposed to do. And, sorry, but this is junk code.
daniel
daniel 2022 年 12 月 26 日
Sorry I fixed the code

サインインしてコメントする。

 採用された回答

Voss
Voss 2022 年 12 月 26 日

0 投票

This code prompts the user to input a sequence of matrices (input a scalar 0 to stop) and sorts the matrices according to the sum of their elements.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

質問済み:

2022 年 12 月 26 日

回答済み:

2022 年 12 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by