Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Image Analyst
Image Analyst am 29 Okt. 2021
Instead of
if x == v
else
end
try
out = all(x==v);
  3 Kommentare
Image Analyst
Image Analyst am 29 Okt. 2021
Bearbeitet: Image Analyst am 29 Okt. 2021
if all(x == v)
out = true;
else
out = false;
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by