I am new at this. I've created a function script with 2 inputs and 2 outputs but when I run it only the answer to the first input/output pair is returned. Why doesnt the second output run?

 채택된 답변

Image Analyst
Image Analyst 2019년 5월 25일

0 개 추천

How did you call it? Did you accept both into variables? Like
[ouput1, output2] = MyFunction(input1, input2)

댓글 수: 4

Image Analyst
Image Analyst 2019년 5월 25일
Kenneth's "Answer" moved here since it's not an actual answer to the original question:
in fact I did, preceeded by the word function [output1, output2]=myfunction(input1, input2) as you state.
No, when you precede it with the word function, like
function [output1, output2]=myfunction(input1, input2)
that is where you define the function - say what it does. It doesn't actually call the function. You have to assign inputs and then call it without the word function, like
a=1;
b=2;
[c, d] = myfunction(a, b)
Kenneth Weintraub
Kenneth Weintraub 2019년 5월 25일
that worked thanks!!!
Image Analyst
Image Analyst 2019년 5월 26일
Can you please "Accept this Answer" then? Thanks in advance.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

2019년 5월 25일

댓글:

2019년 5월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by