Prev: Matlab and FaroArm developer
Next: explain please
From: ClauDe De on 11 May 2010 06:33 Hallo everyone, ok, I hope I can explain my problem properly... Within a loop, I would like to save my variables under a special filename which I want to take out of "B". "B" contains Instrumentnumbers (f.ex.: 2342, 2355, 16019, ... ) Here: size(B) = 1 58 The loop loads a netcdf-file and the variables are created. Now I would like to save them in a MAT-file named after the Instrumentnumber. Something like: save Instr_2342 var1 var2 var3 end of loop But I got no idea how to let it take the next number out of "B" with every loop and save it under that name. I have the feeling that this is quite simple, but I got stuck there... Thanks for your help and comments in advance!!! I really appreciate it!
From: Joshua Arnott on 11 May 2010 06:49 "ClauDe De" <acerxenite(a)yahoo.de> wrote in message <hsbbp0$qlt$1(a)fred.mathworks.com>... > Hallo everyone, > > ok, I hope I can explain my problem properly... > > Within a loop, I would like to save my variables under a special filename which > I want to take out of "B". "B" contains Instrumentnumbers (f.ex.: 2342, 2355, 16019, ... ) Here: size(B) = 1 58 > > The loop loads a netcdf-file and the variables are created. > Now I would like to save them in a MAT-file named after the > Instrumentnumber. > Something like: save Instr_2342 var1 var2 var3 > end of loop > > But I got no idea how to let it take the next number out of "B" with every loop and save it under that name. > > I have the feeling that this is quite simple, but I got stuck there... > > Thanks for your help and comments in advance!!! I really appreciate it! Assuming your B variable is a cell array: for k = 1:length(B) % do some processing save(sprintf('%s',B{k}),'var1','var2','etc'); end
From: ClauDe on 11 May 2010 07:38 > Assuming your B variable is a cell array: > > for k = 1:length(B) > % do some processing > save(sprintf('%s',B{k}),'var1','var2','etc'); > end Thanks for the quick response!!!!! Unfortunately, B is no cell-array... my attempt: turned it into a cell-array (num2cell) But it's not working either... Got this error: ??? Error using ==> save Unable to write file : Invalid argument. mmh... any clue?! Thanks!!
From: ClauDe on 11 May 2010 08:24 > > Assuming your B variable is a cell array: > > > > for k = 1:length(B) > > % do some processing > > save(sprintf('%s',B{k}),'var1','var2','etc'); > > end Oh, and when I run this with k = 1 The created MAT-File is called B{k}.mat ...
From: ClauDe on 11 May 2010 08:38
> Oh, and when I run this with k = 1 > The created MAT-File is called B{k}.mat ... ups... within my testing"rage", I wrote 'B{k}'... of course the name is B{k} then... without apostrophe it's still the array- and/or argument error... |