LogLog Plot is Blank

13 views (last 30 days)
John
John on 26 Feb 2023
Commented: Star Strider on 26 Feb 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?

Accepted Answer

Star Strider
Star Strider on 26 Feb 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 Comments
John
John on 26 Feb 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 on 26 Feb 2023
As always, my pleasure!

Sign in to comment.

More Answers (1)

Alan Stevens
Alan Stevens on 26 Feb 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 Comment
John
John on 26 Feb 2023
Thank you for the answer @Alan Stevens! Wish I could accept more than one answer.

Sign in to comment.

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!