Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
how can i plot using variables from a loop?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
er=2.2;h=0.1588; freq={11 2 3 4 5 6 7 8 9 10};i=0:1:9;i=logical(i); i=freq; for i=1:1:length(freq) lambda_o=30.0/i ko=2.0*pi/lambda_o; F=8.791/(i*sqrt(er)); a=F/sqrt(1+2*h/(pi*er*F)*(log(pi*F/(2*h))+1.7726)); ae=a*sqrt(1+2*h/(pi*er*a)*(log(pi*a/(2*h))+1.7726)); t=(0:0.001:pi/2); x=ko.*ae.*sin(t); j0=besselj(0,x); j2=besselj(2,x); j02p=j0-j2; j02=j0+j2; grad=(ko*ae)^2/480*sum((j02p.^2+(cos(t)).^2.*j02.^2).*sin(t).*0.001); xlabel('ae->');ylabel('grad->'); plot(ae,grad);end; Iam trying to plot ae vs grad graph of a circular patch antenna.The code above which i used produced a blank graph.Iam totally new to MATLAB so please kindly help me with this. Thank you.
0 Kommentare
Antworten (1)
Shoaibur Rahman
am 1 Jan. 2015
You can do this without using a for loop:
er=2.2;h=0.1588;
freq={11 2 3 4 5 6 7 8 9 10};
i=1:1:length(freq);
lambda_o=30.0./i ;
ko=2.0*pi./lambda_o;
F=8.791./(i*sqrt(er));
a=F./sqrt(1+2*h./(pi*er*F).*(log(pi*F./(2*h))+1.7726));
ae=a.*sqrt(1+2*h./(pi*er*a).*(log(pi*a/(2*h))+1.7726));
t=linspace(0,pi/2,length(freq));
x=ko.*ae.*sin(t);
j0=besselj(0,x);
j2=besselj(2,x);
j02p=j0-j2;
j02=j0+j2;
grad=(ko.*ae).^2/480*sum((j02p.^2+(cos(t)).^2.*j02.^2).*sin(t).*0.001);
plot(ae,grad);
xlabel('ae->');ylabel('grad->');
If you want to use for loop:
er=2.2;h=0.1588;
freq={11 2 3 4 5 6 7 8 9 10};
for i=1:1:length(freq)
lambda_o=30.0/i ;
ko=2.0*pi/lambda_o;
F=8.791/(i*sqrt(er));
a=F/sqrt(1+2*h/(pi*er*F)*(log(pi*F/(2*h))+1.7726));
ae(i)=a*sqrt(1+2*h/(pi*er*a)*(log(pi*a/(2*h))+1.7726));
t=(0:0.001:pi/2);
x=ko.*ae(i).*sin(t);
j0=besselj(0,x);
j2=besselj(2,x);
j02p=j0-j2;
j02=j0+j2;
grad(i)=(ko*ae(i))^2/480*sum((j02p.^2+(cos(t)).^2.*j02.^2).*sin(t).*0.001);
end
plot(ae,grad);
xlabel('ae->');ylabel('grad->');
By the way, when you submit any part of code with your question, please use {}Code . Write your code, highlight that, and then click on {}Code button.
Happy New Year!
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!