Prev: Distribute Matlab figures
Next: How can I compute the probability that a set has normal distribution with zero mean
From: antonio ferreira on 28 Jul 2010 05:22 "Steven_Lord" <slord(a)mathworks.com> wrote in message <i2nb26$hu3$1(a)fred.mathworks.com>... > > > "antonio ferreira" <edgar.acferreira(a)gmail.com> wrote in message > news:i2n7lt$1p9$1(a)fred.mathworks.com... > > I have two folders (conf1 and conf2). In these two folders I have the same > > variables. I pretend to use the load command however I am not being able > > to do that. This is the part of the code that I have created: > > > > n_g=2; > > path = pwd; > > Just FYI, by executing this command, you're eliminating any chance of using > the PATH function later in your code. > > > for i =1 : n_g > > load([path num2str(i) '.mat']); > > Call LOAD with an output argument to obtain a struct array whose field names > are the names of the variables from the file, and use dynamic field names > (or regular field names, if you know the variables you want to access when > you write the code) to extract the appropriate field. > > BTW, you should use FULLFILE to construct the string containing the full > path to the file. Your code assumes that PWD ends with a FILESEP; I don't > know if that's guaranteed to be the case. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com The output says 'Unable to read file C:\Documents and Settings\User\Desktop\conf1'. "by executing this command, you're eliminating any chance of using the PATH function later in your code"-not a problem I think; "Call LOAD with an output argument to obtain a struct array whose field names are the names of the variables from the file, and use dynamic field names (or regular field names, if you know the variables you want to access when you write the code) to extract the appropriate field"-did not understand very well. could you please give me a clear example please... I have changed slightly the code but still is not working: n_g=2; nb=conf; cd = pwd; for i =1 : n_g load([cd '\' nb num2str(i)]); end Any more suggestions or recomendations it will be helpfull.Regards
From: us on 28 Jul 2010 06:54 "antonio ferreira" > The output says 'Unable to read file C:\Documents and > Settings\User\Desktop\conf1'. well... OF COURSE(!)... that's exactly what i told you about a day ago... - you're trying to LOAD a FOLDER... - LOAD only works on mat- or ascii- FILES... us
From: Steven_Lord on 28 Jul 2010 09:44
"antonio ferreira" <edgar.acferreira(a)gmail.com> wrote in message news:i2osrs$5bo$1(a)fred.mathworks.com... > "Steven_Lord" <slord(a)mathworks.com> wrote in message > <i2nb26$hu3$1(a)fred.mathworks.com>... *snip* > "Call LOAD with an output argument to obtain a struct array whose field > names are the names of the variables from the file, and use dynamic field > names (or regular field names, if you know the variables you want to > access when you write the code) to extract the appropriate field"-did not > understand very well. could you please give me a clear example please... Look at the first bullet point in the "Troubleshooting: Loading Variables within a Function" section of this documentation page: http://www.mathworks.com/access/helpdesk/help/techdoc/import_export/braietb-1.html#bsdnp13 > I have changed slightly the code but still is not working: > > n_g=2; > nb=conf; > cd = pwd; Now you've locked yourself out from calling the CD function; and if this is a script file, whenever you try to change directory with this variable in the workspace you will (probably) receive an error -- you DEFINITELY won't change directory. > for i =1 : n_g > load([cd '\' nb num2str(i)]); > end > > Any more suggestions or recomendations it will be helpfull.Regards -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com |