Problems with my 2D graph

Hello! Can someone help me to make my graph 2 look like number 1 please? I want the Y axis to be the same
1)
2)
Code
e_inf = 11.7 ;
Wp1 = 1.0856e11;
gamma1 = 2.3518e9 ;
Wp2 = 3.4330e11;
gamma2 = 5.6747e9 ;
Wp3 = 1.0856e12;
gamma3 = 8.8952e9 ;
Wp4 = 3.4330e12;
gamma4 = 3.2292e10;
w1 = 1e13;
w2 = 1e10;
w3 = 1e15;
index = 0;
K = w1:w2:w3;
% Loop is not necessary!
e1 = e_inf - ((Wp1^2)./K.^2+1i*K*gamma1);
e2 = e_inf - ((Wp2^2)./K.^2+1i*K*gamma2);
e3 = e_inf - ((Wp3^2)./K.^2+1i*K*gamma3);
e4 = e_inf - ((Wp4^2)./K.^2+1i*K*gamma4);
f=K;
x=f;
figure
y1 = real(e1);
semilogx(x,y1, 'b-','linewidth',2, 'displayName', 'e_1')
hold on
y2 = real(e2);
semilogx(x,y2, 'g-', 'linewidth',2,'displayName', 'e_2'), grid on
y3 = real(e3);
semilogx(x,y3, 'r-', 'linewidth',2,'displayName', 'e_3'), grid on
y4 = real(e4);
semilogx(x,y4, 'black-', 'linewidth',2,'displayName', 'e_4'), grid on
hold off
legend('toggle');
This statement is incomplete.

8 commentaires

Les Beckham
Les Beckham le 30 Déc 2022
Modifié(e) : Les Beckham le 30 Déc 2022
The code you posted (which you should format as code, by the way) creates graph 2.
If you really meant that you want your graph to look like graph 1, then explain what, specifically, you like about graph 1 and want to replicate in your graph. Is it the line styles (dashed vs. solid)? The legend with no box? The blue axes? The two x axes? The actual shape of the lines, of course, will not match because of the data that you are plotting.
BTW - to format your code, edit the question, select all of the code, and press the left hand button in the CODE section of the toolbar above.
Walter Roberson
Walter Roberson le 30 Déc 2022
The "incomplete" is due to the ":" (colon) at the end of the last line that needs to be ";" (semi-colon) instead.
Walter Roberson
Walter Roberson le 30 Déc 2022
Modifié(e) : Walter Roberson le 30 Déc 2022
With minor changes:
e_inf = 11.7 ;
Wp1 = 1.0856e11;
gamma1 = 2.3518e9 ;
Wp2 = 3.4330e11;
gamma2 = 5.6747e9 ;
Wp3 = 1.0856e12;
gamma3 = 8.8952e9 ;
Wp4 = 3.4330e12;
gamma4 = 3.2292e10;
w1 = 1e13;
w2 = 1e10;
w3 = 1e15;
index = 0;
K = w1:w2:w3;
% Loop is not necessary!
e1 = e_inf - ((Wp1^2)./K.^2+1i*K*gamma1);
e2 = e_inf - ((Wp2^2)./K.^2+1i*K*gamma2);
e3 = e_inf - ((Wp3^2)./K.^2+1i*K*gamma3);
e4 = e_inf - ((Wp4^2)./K.^2+1i*K*gamma4);
f=K;
x=f;
figure
y1 = real(e1);
semilogx(x,y1, 'b-','linewidth',2, 'displayName', 'e_1')
hold on
y2 = real(e2);
semilogx(x,y2, 'g-', 'linewidth',2,'displayName', 'e_2'), grid on
y3 = real(e3);
semilogx(x,y3, 'r-', 'linewidth',2,'displayName', 'e_3'), grid on
y4 = real(e4);
semilogx(x,y4, 'black-', 'linewidth',2,'displayName', 'e_4'), grid on
hold off
L = legend('toggle');
L.Box = 'off';
L.Location = 'southeast';
Walter Roberson
Walter Roberson le 30 Déc 2022
The "incomplete" is due to the ":" (colon) at the end of the last line that needs to be ";" (semi-colon) instead.
Yordani
Yordani le 30 Déc 2022
Hello, I would like the Y axis to be the same
e_inf = 11.7 ;
Wp1 = 1.0856e11;
gamma1 = 2.3518e9 ;
Wp2 = 3.4330e11;
gamma2 = 5.6747e9 ;
Wp3 = 1.0856e12;
gamma3 = 8.8952e9 ;
Wp4 = 3.4330e12;
gamma4 = 3.2292e10;
w1 = 1e13;
w2 = 1e10;
w3 = 1e15;
index = 0;
K = w1:w2:w3;
% Loop is not necessary!
e1 = e_inf - ((Wp1^2)./K.^2+1i*K*gamma1);
e2 = e_inf - ((Wp2^2)./K.^2+1i*K*gamma2);
e3 = e_inf - ((Wp3^2)./K.^2+1i*K*gamma3);
e4 = e_inf - ((Wp4^2)./K.^2+1i*K*gamma4);
f=K;
x=f;
figure
y1 = real(e1);
semilogx(x,y1, 'b-','linewidth',2, 'displayName', 'e_1')
hold on
y2 = real(e2);
semilogx(x,y2, 'g-', 'linewidth',2,'displayName', 'e_2'), grid on
y3 = real(e3);
semilogx(x,y3, 'r-', 'linewidth',2,'displayName', 'e_3'), grid on
y4 = real(e4);
semilogx(x,y4, 'black-', 'linewidth',2,'displayName', 'e_4'), grid on
hold off
ylim([-300 50])
L = legend('toggle');
L.Box = 'off';
L.Location = 'southeast';
Walter Roberson
Walter Roberson le 30 Déc 2022
You cannot see separate lines because when you expand the y axis to cover the same range as the other plot, then the data available for this plot has too little variation in y range to show separate lines.
Walter Roberson
Walter Roberson le 30 Déc 2022
Your example plot has legend items such as 10^21 but I do not see which variable values that is intended to correspond to?

Connectez-vous pour commenter.

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 31 Déc 2022
Modifié(e) : Sulaymon Eshkabilov le 31 Déc 2022
Here is the corrected code:
e_inf = 11.7 ;
Wp1 = 1.0856e11;
gamma1 = 2.3518e9 ;
Wp2 = 3.4330e11;
gamma2 = 5.6747e9 ;
Wp3 = 1.0856e12;
gamma3 = 8.8952e9 ;
Wp4 = 3.4330e12;
gamma4 = 3.2292e10;
w1 = 1e13;
w2 = 1e10;
w3 = 1e15;
index = 0;
K = w1:w2:w3;
% Loop is not necessary!
e1 = e_inf - ((Wp1^2)./K.^2+1i*K*gamma1);
e2 = e_inf - ((Wp2^2)./K.^2+1i*K*gamma2);
e3 = e_inf - ((Wp3^2)./K.^2+1i*K*gamma3);
e4 = e_inf - ((Wp4^2)./K.^2+1i*K*gamma4);
f=K;
x=f;
figure
y1 = real(e1); Wp1 = 1.0856e11;
gamma1 = 2.3518e9 ;
Wp2 = 3.4330e11;
gamma2 = 5.6747e9 ;
Wp3 = 1.0856e12;
gamma3 = 8.8952e9 ;
Wp4 = 3.4330e12;
gamma4 = 3.2292e10;
loglog(x,y1, 'b-.','linewidth',2, 'displayName', '\Gamma = 2.35*10^9')
hold on
y2 = real(e2);
loglog(x,y2, 'g-', 'linewidth',2.5,'displayName', '\Gamma = 5.6747*10^9'), grid on
y3 = real(e3);
loglog(x,y3, 'r--', 'linewidth',2,'displayName', '\Gamma = 8.8952*10^9'), grid on
y4 = real(e4);
loglog(x,y4, 'k:', 'linewidth',2,'displayName', '\Gamma = 3.2292*10^{10}'), grid on
hold off
ylim([11.55 11.705])
legend('toggle'); xlabel('$\omega$', 'interpreter', 'latex'); ylabel('$Re(\epsilon)$', 'interpreter', 'latex')

1 commentaire

Walter Roberson
Walter Roberson le 31 Déc 2022
No, they expect a graph in which the y4 values start about -300

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graph and Network Algorithms dans Centre d'aide et File Exchange

Tags

Question posée :

le 30 Déc 2022

Commenté :

le 31 Déc 2022

Community Treasure Hunt

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

Start Hunting!

Translated by