Keep getting 'ans' output in Matlab function

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

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
end % END
Topperanium
Topperanium 2020년 12월 8일
That's still giving me ans at the end, sadly
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 2020년 12월 8일
That works, thanks. The thing is, I was calling it as file1(scalar,genvec) before

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

 채택된 답변

Stephan
Stephan 2020년 12월 8일

0 개 추천

Call it this way:
[outResult, logoutResult] = file1(scalar, genvec)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

태그

질문:

2020년 12월 8일

댓글:

2020년 12월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by