Save a Variable that from a function on a matrix

조회 수: 6 (최근 30일)
German
German 2014년 5월 12일
댓글: Star Strider 2014년 5월 12일
Im developing a big rutine, in wich i have many function calls inside function calls. In one of those function i get a variable called "mu" that its onli used on the same function, and its part of a "for" cycle, so i get many "mu" variables (for each cycle) that are instantly used and then never more. Y want to save on a vector all those "mu" variables, so i can analize them later, but I dont want to create an output from the function they are created, because that imply making inputs and outputs of the many function calls that my rutine has. Is ther any way to do this? Thanks!

답변 (1개)

Star Strider
Star Strider 2014년 5월 12일
편집: Star Strider 2014년 5월 12일
If I understand what you want, all you need to do is to give mu a subscript, but be sure to refer to it by its subscript in any subsequent statements or function calls if you are using it elsewhere in the loop.
I suggest something like:
for k1 = ...
... do stuff ...
mu(k1) = ... ;
q = fun( ..., mu(k1), ... );
r(k1) = mu(k1) .* k1^2 .* q ... ;
... do stuff ...
end
  댓글 수: 2
German
German 2014년 5월 12일
mm nop, that was no what i ment, its somethink like this:
[X,Y,Z]=function(...)
for i=1:bla
[Xg]=function2(...) -> inside this fn i create mu, and need to be . able on the workspace, or main function
. without transforming it to an output of
. all functions
end
... ... ... end
Need to know all the values of mu "here"
Star Strider
Star Strider 2014년 5월 12일
I misunderstood. See if making mu a global variable would do what you want. (That’s not considered efficient programming practice, but it is sometimes necessary.)

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

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by