I want to print only logical answer as shown in the example
조회 수: 1 (최근 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에서 Get Started with MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!