Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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

Respuesta aceptada

Image Analyst
Image Analyst el 29 de Oct. de 2021
Instead of
if x == v
else
end
try
out = all(x==v);
  3 comentarios
Image Analyst
Image Analyst el 29 de Oct. de 2021
Editada: Image Analyst el 29 de Oct. de 2021
if all(x == v)
out = true;
else
out = false;
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by