Function output problem?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Larry Burroughs
am 20 Okt. 2016
Beantwortet: Star Strider
am 20 Okt. 2016
I made a very simple function (below) for an assignment, and I get two outputs: y and ans. MATLAB only stores the value of ans. I would like to, if possible, suppress the ans output and store the value of the variable y for future use. Any suggestions would be greatly appreciated.
% fn to eval. y for the eq. y = c<x - a>^n
function y = fn_eval(c,a,n,x)
y = c*(x - a)^n;
y
end
0 Kommentare
Akzeptierte Antwort
Star Strider
am 20 Okt. 2016
You can suppress the ‘ans’ output by calling your function as:
y = fn_eval(c,a,n,x)
That will assign the result to ‘y’. You can suppress the independent ‘y’ output by changing your function to:
function y = fn_eval(c,a,n,x)
y = c*(x - a)^n;
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!