why this function is not plotting?
1 view (last 30 days)
Show older comments
a =5;
T = 2E3;
Z = linspace(0,0.1,0.01);
U = (1+2.*Z)./(2.*a.*T);
plot(Z,U)
0 Comments
Answers (1)
Star Strider
on 21 Jul 2022
Look t the linspace result —
a =5;
T = 2E3;
Z = linspace(0,0.1,0.01)
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
U = (1+2.*Z)./(2.*a.*T);
plot(Z,U)
.
3 Comments
Star Strider
on 21 Jul 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.
.
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!