I want to print only logical answer as shown in the example
3 ビュー (過去 30 日間)
古いコメントを表示
function [out] = issortedvector(v)
x = sort(v);
if x == v
else
end
Example
issortedvector( [ -5 -3 10 20 25 29 ] )
ans = logical
1
or
>> issortedvector( [ 5 9 11 8 15 ] )
ans = logical
0
0 件のコメント
採用された回答
Image Analyst
2021 年 10 月 29 日
Instead of
if x == v
else
end
try
out = all(x==v);
3 件のコメント
Image Analyst
2021 年 10 月 29 日
編集済み: Image Analyst
2021 年 10 月 29 日
if all(x == v)
out = true;
else
out = false;
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!