How to Increase plotting speed
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Guan Hao
am 13 Mai 2024
Kommentiert: Guan Hao
am 14 Mai 2024
Hi everyone,I have a big trouble on plotting my results,it took a long time to complete the figure.Is there any method to increase plotting speed?
Thanks for your help!!!
clear
L=0.1;
a=L/2;
v=3e8;
f1=1.2e9;
f2=4.8e9;
f3=10e9;
w1=(2*pi*f1);
w2=(2*pi*f2);
w3=(2*pi*f3);
Z01=50;
Z02=50;
a0=(log(Z02/Z01))./(2.*L);
T=2*a;
k=1;
syms x y w
Am=-5;
%%% Eight section SFG
% Calculate gamma
s=L/8;
for n=1:1:k
V=Am(n);
P_am=((V*cos(n*pi*x/T)))*(exp(-2*1i*(w/v)*x));
P_am_int1(n)=int(P_am,x,[0 s]);
P_am_int2(n)=int(P_am,x,[s 2*s]);
P_am_int3(n)=int(P_am,x,[2*s 3*s]);
P_am_int4(n)=int(P_am,x,[3*s 4*s]);
P_am_int5(n)=int(P_am,x,[4*s 5*s]);
P_am_int6(n)=int(P_am,x,[5*s 6*s]);
P_am_int7(n)=int(P_am,x,[6*s 7*s]);
P_am_int8(n)=int(P_am,x,[7*s 8*s]);
end
Ga1=sum(P_am_int1);
Ga2=sum(P_am_int2);
Ga3=sum(P_am_int3);
Ga4=sum(P_am_int4);
Ga5=sum(P_am_int5);
Ga6=sum(P_am_int6);
Ga7=sum(P_am_int7);
Ga8=sum(P_am_int8);
Ga=[Ga1 Ga2 Ga3 Ga4 Ga5 Ga6 Ga7 Ga8];
Ta=1-((Ga(7:-1:1)).^2);
%%% SFG
section_num=8;
gamma_app8=Ga(section_num);
for m=1:1:section_num-1
gamma_app8=gamma_app8*((Ta(section_num-m)))/(1+abs((gamma_app8*Ga(section_num-m))));
gamma_app8=gamma_app8+Ga(section_num-m);
end
fplot(w,abs(gamma_app8),[0 w3],'-','LineWidth',3)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 13 Mai 2024
tic
L=0.1;
a=L/2;
v=3e8;
f1=1.2e9;
f2=4.8e9;
f3=10e9;
w1=(2*pi*f1);
w2=(2*pi*f2);
w3=(2*pi*f3);
Z01=50;
Z02=50;
a0=(log(Z02/Z01))./(2.*L);
T=2*a;
k=1;
syms x y w
Am=-5;
%%% Eight section SFG
% Calculate gamma
s=L/8;
syms V
n = 1;
P_am=((V*cos(n*pi*x/T)))*(exp(-2*1i*(w/v)*x));
P_am_int1(n)=int(P_am,x,[0 s]);
P_am_int2(n)=int(P_am,x,[s 2*s]);
P_am_int3(n)=int(P_am,x,[2*s 3*s]);
P_am_int4(n)=int(P_am,x,[3*s 4*s]);
P_am_int5(n)=int(P_am,x,[4*s 5*s]);
P_am_int6(n)=int(P_am,x,[5*s 6*s]);
P_am_int7(n)=int(P_am,x,[6*s 7*s]);
P_am_int8(n)=int(P_am,x,[7*s 8*s]);
Ga1 = sum( subs(P_am_int1, V, Am) );
Ga2 = sum( subs(P_am_int2, V, Am) );
Ga3 = sum( subs(P_am_int3, V, Am) );
Ga4 = sum( subs(P_am_int4, V, Am) );
Ga5 = sum( subs(P_am_int5, V, Am) );
Ga6 = sum( subs(P_am_int6, V, Am) );
Ga7 = sum( subs(P_am_int7, V, Am) );
Ga8 = sum( subs(P_am_int8, V, Am) );
Ga=[Ga1 Ga2 Ga3 Ga4 Ga5 Ga6 Ga7 Ga8];
Ta=1-((Ga(end-1:-1:1)).^2);
%%% SFG
section_num=8;
gamma_app8=Ga(section_num);
for m=1:1:section_num-1
gamma_app8=gamma_app8*((Ta(section_num-m)))/(1+abs((gamma_app8*Ga(section_num-m))));
gamma_app8=gamma_app8+Ga(section_num-m);
end
toc
tic
fplot(w,abs(gamma_app8),[0 w3],'-','LineWidth',3)
toc
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Manage Products finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
