LogLog Plot is Blank

조회 수: 9 (최근 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?

채택된 답변

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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by