Creating arrays in auxiliary functions
Show older comments
Hello.
This is how I have my code organized:
function main()
...
function auxiliary1()
...
function auxiliary2()
...
etc..
When I create an array, A(k) inside one of the auxiliary functions, as k increases the previous values of A turn into zero. Does this means that I can only construct an array inside the main function (where k is counting)?
Thank You
Answers (2)
Azzi Abdelmalek
on 13 Jul 2014
0 votes
If you want your variable k to be seen by all your functions, declare it as global in each function, or pass the variable k as input argument in each function
7 Comments
António
on 13 Jul 2014
Azzi Abdelmalek
on 13 Jul 2014
Then, what is your problem?
António
on 13 Jul 2014
Azzi Abdelmalek
on 13 Jul 2014
Edited: Azzi Abdelmalek
on 13 Jul 2014
Maybe you need also to use A as input argument. Without your code it's difficult to guess
António
on 13 Jul 2014
Azzi Abdelmalek
on 13 Jul 2014
Ok, what is your question?
António
on 13 Jul 2014
Image Analyst
on 13 Jul 2014
0 votes
See the FAQ http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F, which basically says to do what Azzi told you.
1 Comment
Image Analyst
on 13 Jul 2014
In main(), do this
x_T(k) = getCoordTransf(Ehat,AA,BB,CC,k);
In getCoordTransf(), do this:
x_T = dot((...........
Categories
Find more on Windows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!