From: King on 16 Apr 2010 17:20 Hi, I have a function file say fun(NL). It does something and saves the data in a file say NLxx.out.mat. Before I call the function with a specific value of NL (NL=08) I go into the function file and change the file name to NL08.out.mat. Again before I call fun(04) I go and edit the function file so the output is written in NL04.out.mat. Is there an automatic way I can change the NLxx.out.mat. For example it takes the input value NL=something and then save it as say NLsomething.out.mat? Thanks for your help.
From: Nicholas Phillips on 16 Apr 2010 22:28 "King" <majumdak(a)gvsu.edu> wrote in message <hqakao$8s3$1(a)fred.mathworks.com>... > Hi, > > I have a function file say fun(NL). It does something and saves the data in a file say > NLxx.out.mat. Before I call the function with a specific value of NL (NL=08) I go into the function file and change the file name to NL08.out.mat. > Again before I call fun(04) I go and edit the function file so the output is written in NL04.out.mat. Is there an automatic way I can change the NLxx.out.mat. For example it takes the input value NL=something and then save it as say NLsomething.out.mat? > > Thanks for your help. is NL always numeric? if so try this: function out = fun(NL) %some code of whatever "fun" is supposed to accomplis goes here of course % this assumes "out" is the variable you want to save, make sure to include the square brackets and spaces as this is basically horizontally concantanating the string. save(['NL' num2str(NL) '.out.mat'],'out') hope this helps, at least it works for me. Now if someone knew how to automate the assignment of variables in a similar fashion that would be outstanding. Nick
From: King on 18 Apr 2010 08:34 "King" <majumdak(a)gvsu.edu> wrote in message <hqakao$8s3$1(a)fred.mathworks.com>... > Hi, > > I have a function file say fun(NL). It does something and saves the data in a file say > NLxx.out.mat. Before I call the function with a specific value of NL (NL=08) I go into the function file and change the file name to NL08.out.mat. > Again before I call fun(04) I go and edit the function file so the output is written in NL04.out.mat. Is there an automatic way I can change the NLxx.out.mat. For example it takes the input value NL=something and then save it as say NLsomething.out.mat? > > Thanks for your help. Thank you so much. It worked!
|
Pages: 1 Prev: HELP MEMORY for your options Next: Identifying workspaces |