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

Stephen23
Stephen23 2019년 10월 7일
편집: Stephen23 2019년 10월 7일
"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...

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

답변 (1개)

Walter Roberson
Walter Roberson 2019년 10월 7일

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)

카테고리

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

질문:

2019년 10월 7일

편집:

2019년 10월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by