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

2 次查看(过去 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

采纳的回答

Image Analyst
Image Analyst 2021-10-29
Instead of
if x == v
else
end
try
out = all(x==v);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by