LogLog Plot is Blank

10 ビュー (過去 30 日間)
John
John 2023 年 2 月 26 日
コメント済み: Star Strider 2023 年 2 月 26 日
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?
  1 件のコメント
Stephen23
Stephen23 2023 年 2 月 26 日

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2023 年 2 月 26 日
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 件のコメント
John
John 2023 年 2 月 26 日
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 2023 年 2 月 26 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2023 年 2 月 26 日
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 件のコメント
John
John 2023 年 2 月 26 日
Thank you for the answer @Alan Stevens! Wish I could accept more than one answer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by