필터 지우기
필터 지우기

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

조회 수: 1 (최근 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에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by