save in excel file inside a for loop

1 view (last 30 days)
hi i want to save the values of a vector in a xls file. The value s change inside a for loop... the variable is avg_rayleigh
clc
syms k s=sqrt(2/pi); m=2; w=4.527; S=1; sigma=1.42558; s_chi=0.42552; freq=[100:100:700]'
for i=100:100:700 freq=i; f=i*1e6;
[hm,P,er,k0,beta,er_eff,L]=parameter(f);
r=sqrt(er_eff)./er; theta=2*pi/5;
phi=3*pi/7; %phid=acosd(r.*sin(theta)) distr='Rayleigh' %coifficients [d1,d2]=coifp(k0,beta,L,er_eff,er,theta,phi);
d=d2;
if strcmp(distr,'Rayleigh') y=(sqrt(2/pi)*P*s*d)*1e3;
avg_rayleigh=[freq y]
%xlswrite('resultsmean.xls',avg_rayleigh,'sheet1','A1','B1') %xlswrite('out.xls',freq','sheet1','A1') %xlswrite('out.xls',avg_rayleigh(:,1),'sheet1','A1') %xlswrite('out.xls',avg_rayleigh(:,2),'sheet1','B1')
elseif strcmp(distr,'chi')
y=((15/8)*sqrt(2/pi)*s_chi*d*P)*1e3;
avg_chi=[freq y];
elseif strcmp(distr,'nakagami') y=((2/pi)*P*d*sqrt(w/m)*(gamma(m+1/2)/gamma(m)))*1e3;
avg_nakagami=[freq(i) y]
elseif strcmp(distr,'rician')
A=S/(sqrt(2)*sigma); I=(2*sqrt(2)/pi)*P*d*sigma*exp(-S^2/(2*sigma^2)); r=factorial(k); y=(I*vpa(symsum( A^(2*k)*gamma(k+3/2)/(r^2),0,inf),4))*1e3;
avg_rician=[freq y];
end end

Accepted Answer

Stalin Samuel
Stalin Samuel on 21 Jan 2017
here you can see the Example code which has the solution
  1 Comment
george veropoulos
george veropoulos on 21 Jan 2017
thank you.... i have use the num2str it is more simpel thna the printf.. but i cant find a similar example

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!