Keep getting 'ans' output in Matlab function

12 visualizaciones (últimos 30 días)
Topperanium
Topperanium el 8 de Dic. de 2020
Comentada: Topperanium el 8 de Dic. de 2020
I've combed this forum for hours trying to find a fix for this but can't seem to. On several functions I have written, I keep getting an extra ans as well as my outputs. I've tried several fixes; even throwing semicolons around but nothing has fixed this. Thank you in advance
function [out,logout] = file1(scalar,genvec)
if scalar == 0
out = 2
else
out = 1
end
if round(genvec) == genvec
logout = 1
else
logout = 0
end
  4 comentarios
Ive J
Ive J el 8 de Dic. de 2020
Oh, I assume you call your function as
file1(scalar, genvec)
Do it as
[out, logout] = file1(scalar, genvec)
% or:
out = file1(scalar, genvec)
% or:
[~, logout] = file1(scalar, genvec)
Topperanium
Topperanium el 8 de Dic. de 2020
That works, thanks. The thing is, I was calling it as file1(scalar,genvec) before

Iniciar sesión para comentar.

Respuesta aceptada

Stephan
Stephan el 8 de Dic. de 2020
Call it this way:
[outResult, logoutResult] = file1(scalar, genvec)

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by