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

1 Ansicht (letzte 30 Tage)
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');

Akzeptierte Antwort

Voss
Voss am 3 Mär. 2024
Bearbeitet: Voss am 3 Mär. 2024
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');

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by