Matlab passing variables to a function- I want these variables updated

1 次查看(过去 30 天)
I have several instances in my matlab code wherein I want to pass varaibles to a function -
say,
Function A calls Function B passing an argument x.
x is updated by Function B.
Now, I want to use this updated value of x in Function A.
But this does not seem possible.
One way is that I declared x as global in function B and function A.
But if I do not want to do that, what is the best way to handle such a scenario?
Kajal

采纳的回答

the cyclist
the cyclist 2015-8-2
编辑:the cyclist 2015-8-2
Pass it back out again:
[x] = function B(x)
x = 2*x;
Call it like this, from A:
x = B(x)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by