Date: Jan 23, 2013 8:59 AM
Subject: Re: Problem with Undefined variable
On 1/23/2013 6:33 AM, Camilo Diaz wrote:
> folder = 'Data';
> % Example: folder = 'C:\Temp\Data';
> % By default the sheet name is ISONE CA. However, it can easily be changed
> % to ME, CT, VT, NH, RI, SEMASS, WCMASS or NEMASSBOST to extract zonal data
> sheetname = 'ISONE CA';
> % Import data for 2004
> if strcmp(sheetname, 'ISONE CA')
> NEData = dataset('XLSFile',
> sprintf('%s\\2004_smd_hourly.xls',folder,yr), 'Sheet', 'NEPOOL');
> When I try to run it, I get:
> Undefined function or variable 'yr'.
> Error in importData (line 18)...
> What can I do? I'm no expert in Matlab but I want to learn.
The sprintf() call used to build a file name expects a folder and year
value...looks like you've munged on the original script perhaps and left
the definition of the folder at the top of the script but took out the
year (variable yr).
I suspect the insertion of '2004' into the format string below as used
in the dataset() call also probably won't create a usable file name as well.
I'd suggest getting the original script again and just setting
yr=2004; or whatever year you want at the same point in the script
where the 'folder=' line is...then the yr variable will be defined.