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: Saving files
Replies: 3   Last Post: Jun 18, 2014 5:28 AM

Advanced Search

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

Posts: 311
Registered: 6/14/06
Re: Saving files
Posted: Jun 17, 2014 3:01 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Ana Beatriz " <asdc1g13@soton.ac.uk> wrote in message <lnq1bp$ncq$1@newscl01ah.mathworks.com>...
> "Ana Beatriz " <asdc1g13@soton.ac.uk> wrote in message <lnq0p1$lr6$1@newscl01ah.mathworks.com>...
> > Dear all,
> >
> > First of all, I should apologise for my first post. I rewrote my code and now the problem I had before was solved.
> > Now I have another problem: I cannot save my sequential files. The error message is "Error using save. Filename is too long". I want to save the files per year (such as bath2006_proc.xyz; bath2007_proc.xyz;...).
> > I suppose that, as soon as it is inside the loop, it should work, right?
> > Please, could someone give me any clue about it?
> >
> > Best wishes,
> > Ana
> >
> > for y=2006:2014
> > bath = sprintf('bath%d.xyz', y);
> > if exist (bath, 'file');
> > data = load(bath);
> > else
> > fprintf ('File %s does not exist.\n', bath);
> > end
> > x=data(:,1); %Easting coordinates
> > y=data(:,2); %Northing coordinates
> > z=data(:,3); %Depth
> > %Inverting signals (negative depths are above the water and vice-versa
> > z_cd=z*-1; %Depth in Chart Datum
> > %Converting to Ordnance Datum (-1.98m)
> > z_od=z_cd-1.98; %Depth in OD
> > %Saving
> > file=sprintf('bath%s_proc.xyz',y);
> > save(file);
> > end

>
>
> Sorry,
> I forgot to say that I want the bath2006_proc.xyz as a matrix format [x y z z_cd z_od]. I have already tried some ways to do that, but I don't know how to make it work...
>
> Thank you.


If you haven't figured it out already, Ana, note that you are defining y twice--the first time at the beginning of your loop (for y = 2006:2014) and the second time when you reassign the second column to y = data(:,2)
So the line
file=sprintf('bath%s_proc.xyz',y);
is trying to assign the entire column of y to the file name.

Barry



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

[Privacy Policy] [Terms of Use]

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