It keeps giving me an error on my xlim and the graph that it gives me isn't complete

2 次查看(过去 30 天)
Q = 9.4*10.^(-6);
q = 2.4*10.^(-5);
epsilon= 0.885*10*(-12);
R=0.1;
z=linspace(0,0.3, 1000);
F=(Q*q*z) *((1-z)/(sqrt(z.^2+R.^2)))/(2*epsilon);
plot(z,F); xlim('[1 0.3]');
xlabel('z'); ylabel('F');

采纳的回答

Voss
Voss 2024-3-3
编辑:Voss 2024-3-3
xlim should be specified as a 1x2 numeric vector of increasing values, e.g.,
xlim([0.3 1]);
not as a character vector (with single-quotes)
xlim('[0.3 1]');
In this case your vector z has elements ranging from 0 to 0.3, and the plot is done with respect to z, so it's not clear why you want to set the x-limits outside the range of values in z. If you think the plot is incomplete, maybe you should change the definition of z to include higher values?
Q = 9.4e-6; % use "e" notation instead of "*10.^"
q = 2.4e-5;
% epsilon= 0.885*10*(-12); % should this one be 10.^(-12) instead of 10*(-12)?
epsilon= 0.885e-12;
R=0.1;
% z=linspace(0,0.3, 1000);
z = linspace(0,1,1000); % make z range from 0 to 1, for example
F=(Q*q*z) .*((1-z)./(sqrt(z.^2+R.^2)))/(2*epsilon);
% ^^ ^^ element-wise multiplication and division required here
plot(z,F); %xlim([0.3 1]);
xlabel('z'); ylabel('F');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by