Path: news.mathworks.com!not-for-mail
From: "ragab Rabeiy" <r_rabeiy@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: xlswrite
Date: Thu, 15 Oct 2009 14:40:22 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 52
Message-ID: <hb7c8m$3u1$1@fred.mathworks.com>
References: <hb6s4f$evt$1@fred.mathworks.com> <pQEBm.2947$4E.1354@newsfe08.iad>
Reply-To: "ragab Rabeiy" <r_rabeiy@yahoo.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255617622 4033 172.30.248.37 (15 Oct 2009 14:40:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Oct 2009 14:40:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2041704
Xref: news.mathworks.com comp.soft-sys.matlab:577551


"Nasser Abbasi" <nma@12000.org> wrote in message <pQEBm.2947$4E.1354@newsfe08.iad>...
> 
> "ragab Rabeiy" <r_rabeiy@yahoo.com> wrote in message 
> news:hb6s4f$evt$1@fred.mathworks.com...
> >i am a new user in Matlab, and i faced small problem, could u please help 
> >me??
> >
> > this problem is: for the following code, Matlab writes only in Excel the 
> > final value (pi*5),
> >
> > and I want it to write all the data from 1 to 5.
> >
> > for x=1:5;
> > m=pi*x;
> > xlswrite('file.xls', m)
> > end
> 
> 
> becuase each time in the loop, you are starting all over and writing to a 
> new file.xls. The old file.xls is overwritten. there is no append by 
> default.
> 
> As mentiod, no loop is neede, write the whole matrix data in one write. see 
> help on how to make different sheets if you want.
> 
> --Nasser 
> 
Thank you for u replay, 
indeed it is only xlswrite test, but i am using it in a larger code, and when I removed for...end, I got error. the following is a larger code but not the largest one, also it is part of my original code.

clc
%%part of :convert to wind direction 
wd=66;
phi=wd*pi/180;
m=xlsread('data', 'point_data','a2:e20');
x=m(:,3); y=m(:,4); z=m(:,5);
n=size(x,1); 
for j=1:n;
xr=x(j,:);
yr=y(j,:);
zr=z(j,:);
xs=3589800 ; ys=5741200; zs=511.05;
X=(xr-xs); Y=(yr-ys);
%% convert to wind direction coordinates
theta=atan((xr-xs)/(yr-ys));
x_=((xr-xs)/sin(theta))*cos(phi-theta);
y_=((xr-xs)/sin(theta))*sin(phi-theta);
   C=x_*.25+y_*.025;
     xlswrite ('test.xls',C)
end

the same problem i got only the last C value in the excel sheet. could you help in it please.