Creating arrays in auxiliary functions
12 views (last 30 days)
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
0 Comments
Answers (2)
Azzi Abdelmalek
on 13 Jul 2014
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
Image Analyst
on 13 Jul 2014
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((...........
See Also
Categories
Find more on Multidimensional Arrays 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!