Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Problem with Undefined variable
Replies: 3   Last Post: Jan 23, 2013 10:57 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dpb

Posts: 6,693
Registered: 6/7/07
Re: Problem with Undefined variable
Posted: Jan 23, 2013 8:59 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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');
> else

...

>
> 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.

sprintf('%s\\2004_smd_hourly.xls',folder,yr)

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.

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.