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:42:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 45
Message-ID: <hb7cbr$a4l$1@fred.mathworks.com>
References: <hb6s4f$evt$1@fred.mathworks.com> <hb7104$dus$1@fred.mathworks.com>
Reply-To: "ragab Rabeiy" <r_rabeiy@yahoo.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255617723 10389 172.30.248.35 (15 Oct 2009 14:42:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Oct 2009 14:42:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2041704
Xref: news.mathworks.com comp.soft-sys.matlab:577552


"Branko " <bogunovic@mbss.org> wrote in message <hb7104$dus$1@fred.mathworks.com>...
> "ragab Rabeiy" <r_rabeiy@yahoo.com> wrote in message <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
> 
> Why do you use for loop? No need in this case:
> x=1:5;
> m=pi*x;
> xlswrite('filename.xls', m)
> 
> Branko

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.