why this function is not plotting?

1 visualizzazione (ultimi 30 giorni)
SAHIL SAHOO
SAHIL SAHOO il 21 Lug 2022
Commentato: Star Strider il 21 Lug 2022
a =5;
T = 2E3;
Z = linspace(0,0.1,0.01);
U = (1+2.*Z)./(2.*a.*T);
plot(Z,U)

Risposte (1)

Star Strider
Star Strider il 21 Lug 2022
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 Commenti
SAHIL SAHOO
SAHIL SAHOO il 21 Lug 2022
%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 il 21 Lug 2022
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.
.

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by