From: kavon hooshiar on 7 Jun 2010 10:25 hi, when i use save with a character array stored in a variable i get this error: K>> save(filename_mat,p) ??? Error using ==> save Argument must contain a string. my code is: (after profile on and profile viewer) filename_mat=['data\' datestr(date,29) '_profile_mat_8state_OF1']; p = profile('info'); save(filename_mat,p) for the life of me i cant figure out the difference between a character array and a string, or how to convert to a string to make the save function work. thanks in advance
From: Walter Roberson on 7 Jun 2010 10:42 kavon hooshiar wrote: > hi, when i use save with a character array stored in a variable i get > this error: > K>> save(filename_mat,p) > ??? Error using ==> save > Argument must contain a string. > > > my code is: (after profile on and profile viewer) > > filename_mat=['data\' datestr(date,29) '_profile_mat_8state_OF1']; > p = profile('info'); > save(filename_mat,p) > > for the life of me i cant figure out the difference between a character > array and a string, or how to convert to a string to make the save > function work. A string is a character row vector. Your problem is not with the file name, but rather with what you are trying to save. When you use the functional form of save, save(), you need to pass a string containing the _name_ of the variable; instead you are passing in the _value_ of p, and p is a structure. If it is p itself you wish to save, pass 'p' rather than p .
From: kavon hooshiar on 7 Jun 2010 10:54 Walter Roberson <roberson(a)hushmail.com> wrote in message <vz7Pn.33754$TL5.28303(a)newsfe24.iad>... > kavon hooshiar wrote: > > hi, when i use save with a character array stored in a variable i get > > this error: > > K>> save(filename_mat,p) > > ??? Error using ==> save > > Argument must contain a string. > > > > > > my code is: (after profile on and profile viewer) > > > > filename_mat=['data\' datestr(date,29) '_profile_mat_8state_OF1']; > > p = profile('info'); > > save(filename_mat,p) > > > > for the life of me i cant figure out the difference between a character > > array and a string, or how to convert to a string to make the save > > function work. > > A string is a character row vector. > > Your problem is not with the file name, but rather with what you are > trying to save. When you use the functional form of save, save(), you > need to pass a string containing the _name_ of the variable; instead you > are passing in the _value_ of p, and p is a structure. If it is p itself > you wish to save, pass 'p' rather than p . Thanks!
|
Pages: 1 Prev: Fault signal Next: How to assign a long text to a DocBlock via the command line? |