필터 지우기
필터 지우기

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by