Marco
Marco

Reputation: 129

An array is unavailable after running matlab code

When I run the below code, values of vf are printed in each iteration step. But after the code completely finished, when I type plot(vf) I get the error:

Unrecognized function or variable 'vf'.

Here is my code:

global Y
global vf
vf=[];
c=0;
for i=0:100:500
    c=c+1;
%%this is a function by which I read the data for Y
    readdata(i);    
    vf(cnt) = mean(mean(Y .* Y))
end

Could somebody please help me with solving this problem?

Upvotes: 1

Views: 36

Answers (1)

Rotem
Rotem

Reputation: 32094

The question is a little awkward with all the global declarations.

I suppose the solution is declaring global vf before using plot(vf):

global vf
plot(vf)

See global documentation.

In case is't not working, it's hard telling why.

Upvotes: 2

Related Questions