フィルターのクリア

I want to print only logical answer as shown in the example

1 回表示 (過去 30 日間)
Manav Divekar
Manav Divekar 2021 年 10 月 29 日
コメント済み: Manav Divekar 2021 年 10 月 29 日
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

採用された回答

Image Analyst
Image Analyst 2021 年 10 月 29 日
Instead of
if x == v
else
end
try
out = all(x==v);
  3 件のコメント
Image Analyst
Image Analyst 2021 年 10 月 29 日
編集済み: Image Analyst 2021 年 10 月 29 日
if all(x == v)
out = true;
else
out = false;
end
Manav Divekar
Manav Divekar 2021 年 10 月 29 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by