why this function is not plotting?
Mostrar comentarios más antiguos
a =5;
T = 2E3;
Z = linspace(0,0.1,0.01);
U = (1+2.*Z)./(2.*a.*T);
plot(Z,U)
Respuestas (1)
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 comentarios
Z = linspace(0,0.1,0.01)
to go from 0 to 0.1 in steps of 0.01. If that's the intention, linspace is not the right function to use. The colon, : operator is.
y = 0:0.01:0.1
@Star Strider I suspect you changed the third input in your call to linspace to 150 after you evaluated the code but before you published, as that call shouldn't have created a 1000 element vector. I don't know if you want to re-evaluate your answer to remove that discrepancy.
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.
.
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


