How to creat functions that return >1 Variables

조회 수: 6 (최근 30일)
Sebastian
Sebastian 2011년 2월 7일
This may be a dumb question, but I'm having problems on creating functions that return more than 1 value. Let me give you an example:
function [addi, subt]= addsub(a,b)
%Addiert und Subtrahiert zwei Werte a, b. addsub(a,b)
c=a+b;
d=a-b;
addi=c;
subt=d;
end
If I call the function from the command window with: addsub(9,10) It returns ans=19 . So my question is, how can i tell matlab to return 19 and -1 ?
Thanks in Advance Sebastian

채택된 답변

Sebastian
Sebastian 2011년 2월 7일
well, silly me. I found out, how to call the function:
[ret1 , ret2]=addsub(9,10)
ret1 = 19
ret2 = -1
thx. is there a way to close this thread ?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 2월 7일
Accept your own answer. It won't close the thread but it will show it as being "solved".

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by