필터 지우기
필터 지우기

Passing on arguments within functions

조회 수: 1 (최근 30일)
Mary
Mary 2011년 7월 28일
Hello there,
I have a question concerning passing variables from one function to the other, when executing a several functions, which build on each other.
For example
function [a, r, c] = func01 (s,t,y)
....
function [u,v,w] = func02 (a,b,d)
for 'a' i always get "Input argument is undefined" (although it seems to be in the workspace). I just can't figure out how to make it work. :( It's basic, I know, but still. Can anyone please tell me how to pass on arguments from one function to the other? Thanks!
  댓글 수: 2
Oleg Komarov
Oleg Komarov 2011년 7월 28일
Is func02 a subfunction?
Matt Tearle
Matt Tearle 2011년 7월 28일
How are you calling func02? And, as Oleg asks, what kind of function is func02 -- separate/regular function, subfunction of func01, nested function...?

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

답변 (1개)

the cyclist
the cyclist 2011년 7월 28일
As mentioned in the comments, it's not good enough for the variables to be in the workspace, if func02 is being called from inside func01. You have to pass the variable to func01, which can then pass it to func02.
If func02 is not being called from inside func01, it's not clear what the issue is. Are you able to post a snippet of code that exhibits the error?

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by