Prev: Matlab and FaroArm developer
Next: explain please
From: Joshua Arnott on 11 May 2010 08:56 "ClauDe " <acerxenite(a)yahoo.de> wrote in message <hsbfir$pba$1(a)fred.mathworks.com>... > > 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!! ids = [1:4]; for k = 1:length(ids) save(sprintf('instr_%i',ids(k)),'vartosave') end Have a look at the sprintf documentation to understand why this works. help sprintf
From: ImageAnalyst on 11 May 2010 09:00 ClauDe If, as you said earlier, B is a numerical array, not a cell array, then do this: folder = 'c:\whatever'; baseFileName = sprintf('Instr_%d', B(k)); fullFileName = fullfile(folder, baseFileName); save(fullFileName, 'var1', 'var2'); The key is to use parentheses instead of braces.
From: ClauDe on 11 May 2010 09:14
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <24cae0c7-d714-4ee1-a1cd-1d992c251b57(a)24g2000yqy.googlegroups.com>... > ClauDe > If, as you said earlier, B is a numerical array, not a cell array, > then do this: > > folder = 'c:\whatever'; > baseFileName = sprintf('Instr_%d', B(k)); > fullFileName = fullfile(folder, baseFileName); > save(fullFileName, 'var1', 'var2'); > > The key is to use parentheses instead of braces. It works!!!!!!! :-) THANK YOU SO MUCH!!! |