im quite new to matlab but trying to make a little game in matlab. when i started i used a new m file every time i made a new part. now i'm trying to put them all in 1 m-file using nested functions. the probleme is that i used load/save to store my information so you could continue an other time, but now it gives the next error(when combined in 1 m-file:
??? Error using ==> load
Attempt to add "keuzem" to a static workspace.
See MATLAB Programming, Restrictions on Assigning to Variables for
details.
Error in ==> RPGfinal at 7
load('BartRPG.mat')
i know i get a error because its i a static workspace but isn't there any way i can save my varaibles and load then an other time. predesignating then before loading also doesn't work.
i will post the m-file if its nessesary,
hope someone can help me.
bart,
Student
PS. please dont mind my english i'm living in the netherlands.
i can load the .mat file in my main function but not in the nested, so question is; is there a way to load a .mat file in a nested fuction?
sorry for the extra post
That is correct. You can't "poof" variables into the workspace of a nested
function like this.
> i know i get a error because its i a static workspace but isn't there any
> way i can save my varaibles and load then an other time. predesignating
> then before loading also doesn't work.
Specify an output argument for LOAD.
mydata = load('BartRPG.mat');
Then you're not attempting to add variables to the workspace, you're simply
adding fields to a variable that already exists. Since the error message
indicates that one of the variables in that MAT-file is named keuzem, with
this approach you'd need to refer to it as mydata.keuzem -- or if you wanted
to change the rest of your code as little as possible, put this line
immediately after your LOAD call:
keuzem = mydata.keuzem;
> i will post the m-file if its nessesary,
>
> hope someone can help me.
>
> bart,
> Student
> PS. please dont mind my english i'm living in the netherlands.
Your English was fine. Just one suggestion, though -- "i" is sqrt(-1). "I"
is the person who's speaking :)
--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ