Global Variables turn to empty ones once called inside a function?

I have one main program, in which I set a variable
prop = [210000 0.3 4];
The cells from variable prop are called inside a function like this:
1->E=prop(1);
2->v=prop(2);
3->t=prop(3);
I ran the Main program and it gave me the Error "Index exceeds matrix dimensions" on line 1.
I declared prop matrix as global in both main script and function .
I ran it on debug mode and I realised that, even when prop matrix is declared global in both main script and function, once the function is called, on the workspace prop matrix is empty, like below:
prop=[]
Why is this happening, since I have declared the matrix as global? How can I fix this?
Thanks in advance.

Answers (1)

The above would happen if you declare the variable to be global after you initialize it. It would also happen if you did not declare the variable to be global in the same workspace that you initialize it.

Categories

Asked:

on 4 Dec 2016

Answered:

on 4 Dec 2016

Community Treasure Hunt

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

Start Hunting!