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 Comment

Stephen23
Stephen23 on 7 Oct 2019
Edited: Stephen23 on 7 Oct 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...

Sign in to comment.

Answers (1)

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)

Categories

Asked:

on 7 Oct 2019

Edited:

on 7 Oct 2019

Community Treasure Hunt

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

Start Hunting!