Multiple output functions don't work

All my multiple output functions can't work. I install it again, it still can't work.
Please help me,thanks very much.
The code used to be good, I can get multiple answers.
This one is just for test,and my computer simply shows the first answer.
if A = 1, B = 2,the answer is ans = 2
function [C,D] = jiafa(A,B)
C = A+1;
D = B+6
end

1 Kommentar

Stephen23
Stephen23 am 7 Okt. 2019
Bearbeitet: Stephen23 am 7 Okt. 2019
"All my multiple output functions can't work. I install it again, it still can't work."
Rather than assuming a fault and drastically reinstalling MATLAB, it would be much simpler to just work through the introductory tutorials, which teach very basic MATLAB concepts (such as how to call functions with multiple output arguments):
Or read the function help, which also has examples of multiple outputs:
Or simply use your favorite internet search engine...

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 7 Okt. 2019

1 Stimme

You need to assign to multiple variables if you want to get both the 2 and 8 output.
[first_output, second_output] = jiafa(1, 2)

Kategorien

Gefragt:

am 7 Okt. 2019

Bearbeitet:

am 7 Okt. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by