The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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: 312
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 " <> wrote in message <lnq1bp$ncq$>...
> "Ana Beatriz " <> wrote in message <lnq0p1$lr6$>...
> > 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;;...).
> > 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('', 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('',y);
> > save(file);
> > end

> Sorry,
> I forgot to say that I want the 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
is trying to assign the entire column of y to the file name.


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.