Error Reference to a cleared variable
Mostrar comentarios más antiguos
Hi I am trying to load a .mat file that has a matrix array of 2500 rows x 75 columns, and then create a new file name x that has values from all rows and columns 1 to 66. This is my code:
load myfile.mat
x = myfile(:,:);
x=x(:,1:66);
I then get an Error that says Reference to cleared variable myfile. I used this same code with a .txt file and it worked, but have been stuck trying to figure out for hours why it wouldnt work for a .mat file. Any advice would be huge help for me.
3 comentarios
Matthew Eicholtz
el 5 de Oct. de 2016
Is the matrix array in myfile.mat called myfile? Also, no need for the colons.
Use
x = myfile;
instead of
x = myfile(:,:);
meechellevdm
el 5 de Oct. de 2016
meechellevdm
el 5 de Oct. de 2016
Respuestas (1)
Steven Lord
el 5 de Oct. de 2016
6 votos
If this is in a function and you use clear all or clear myfile inside that function, remove the clear all and/or clear myfile calls.
If it's inside a function but you don't call clear all please post a simplified version of that function with which you can reproduce the error.
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!