why this function is not plotting?

조회 수: 1 (최근 30일)
SAHIL SAHOO
SAHIL SAHOO 2022년 7월 21일
댓글: Star Strider 2022년 7월 21일
a =5;
T = 2E3;
Z = linspace(0,0.1,0.01);
U = (1+2.*Z)./(2.*a.*T);
plot(Z,U)

답변 (1개)

Star Strider
Star Strider 2022년 7월 21일
Look t the linspace result —
a =5;
T = 2E3;
Z = linspace(0,0.1,0.01)
Z = 1×0 empty double row vector
U = (1+2.*Z)./(2.*a.*T);
plot(Z,U)
a =5;
T = 2E3;
Z = linspace(0,0.1,150) % 'linspace' Now Produces A Vector
Z = 1×1000
0 0.0001 0.0002 0.0003 0.0004 0.0005 0.0006 0.0007 0.0008 0.0009 0.0010 0.0011 0.0012 0.0013 0.0014 0.0015 0.0016 0.0017 0.0018 0.0019 0.0020 0.0021 0.0022 0.0023 0.0024 0.0025 0.0026 0.0027 0.0028 0.0029
U = (1+2.*Z)./(2.*a.*T);
plot(Z,U)
.
  댓글 수: 3
SAHIL SAHOO
SAHIL SAHOO 2022년 7월 21일
%thanks for the help.
%any idea how to shaded between the two curves ?
clc
clear all
a =5;
T = 2E3;
Z = linspace(0,0.1,150)
Z = 1×150
0 0.0007 0.0013 0.0020 0.0027 0.0034 0.0040 0.0047 0.0054 0.0060 0.0067 0.0074 0.0081 0.0087 0.0094 0.0101 0.0107 0.0114 0.0121 0.0128 0.0134 0.0141 0.0148 0.0154 0.0161 0.0168 0.0174 0.0181 0.0188 0.0195
U = (1+2.*Z)./(2.*a.*T);
V = (a.*Z)./(1+2.*Z);
plot(Z,log10(U))
hold on
plot(Z,log10(V))
hold off
grid on
========================================
Star Strider
Star Strider 2022년 7월 21일
Shading between them is straightforward —
% clc
% clear all
a =5;
T = 2E3;
Z = linspace(0,0.1,150);
U = (1+2.*Z)./(2.*a.*T);
V = (a.*Z)./(1+2.*Z);
Lv = Z>0;
UL10 = log10(U(Lv));
VL10 = log10(V(Lv));
figure
patch([Z(Lv) flip(Z(Lv))], [UL10 flip(VL10)], 'g', 'FaceAlpha',0.25)
hold on
plot(Z,log10(U))
plot(Z,log10(V))
hold off
grid on
The use of ‘Lv’ here is to avoid using values of ‘Z’ equal to 0 becausse the log of 0 in any base is -Inf, and the patch function will not work with non-finite values.
.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by