LogLog Plot is Blank

17 vues (au cours des 30 derniers jours)
John
John le 26 Fév 2023
Commenté : Star Strider le 26 Fév 2023
I am unable to plot anything on a loglog plot with this code:
%Paschen Curve Plotting for H2
p = 1.2; %Torr
d = 20; %cm
GamSE = 1;
%Constants
A = 4.8;
B = 136;
dM = 20*0.01; %Convert units to m
%For Graphing
NumG = B.*x;
DenG = log(A.*x) - log(log(1 + 1/GamSE));
y = (B.*x)/((log(A.*x) - log(log(1 + 1/GamSE)))*dM);
x = logspace(-1,4,50);
loglog(x,y)
hold on
grid on
xlabel('p*d (Torr-cm)')
ylabel('Eb (V/m)')
hold off
It's just blank. I have tried modfiying the limit of the logspace call since the equation should exponetially grow for x < 1 and this still didn't fix it. What am doing incorrectly here?

Réponse acceptée

Star Strider
Star Strider le 26 Fév 2023
Use element-wise division:
y = (B.*x)/((log(A.*x) - log(log(1 + 1/GamSE)))*dM);
↑ ← HERE
and it works!
%Paschen Curve Plotting for H2
p = 1.2; %Torr
d = 20; %cm
GamSE = 1;
%Constants
A = 4.8;
B = 136;
dM = 20*0.01; %Convert units to m
x = logspace(-1,4,50);
%For Graphing
NumG = B.*x;
DenG = log(A.*x) - log(log(1 + 1/GamSE));
y = (B.*x)./((log(A.*x) - log(log(1 + 1/GamSE)))*dM);
loglog(x,y)
hold on
grid on
xlabel('p*d (Torr-cm)')
ylabel('Eb (V/m)')
hold off
Warning: Negative data ignored
Wioth matrix division ratther than array division, ‘y’ is a scalar. Scalars only plot with markers, since a lline has to be defined by at least two (x,y) pairs.
Forgetting do to element-wise division is probably the most common problem I see here.
.
  2 commentaires
John
John le 26 Fév 2023
Thank you @Star Strider, I wasn't aware that I needed to do it for that division symbol too. I did notice that the original function was a scalar rather than an array but wasn't sure why.
Star Strider
Star Strider le 26 Fév 2023
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (1)

Alan Stevens
Alan Stevens le 26 Fév 2023
Like this? (I've assumed you want log base 10 everywhere):
%Paschen Curve Plotting for H2
p = 1.2; %Torr
d = 20; %cm
GamSE = 1;
%Constants
A = 4.8;
B = 136;
dM = 20*0.01; %Convert units to m
%For Graphing
x = logspace(-1,4,50);
NumG = B.*x;
DenG = log10(A.*x) - log10(log10(1 + 1/GamSE));
y = (B.*x)./((log10(A.*x) - log10(log10(1 + 1/GamSE)))*dM); % dot divide
loglog(x,y)
hold on
grid on
xlabel('p*d (Torr-cm)')
ylabel('Eb (V/m)')
hold off
  1 commentaire
John
John le 26 Fév 2023
Thank you for the answer @Alan Stevens! Wish I could accept more than one answer.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by