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');
0 件のコメント
採用された回答
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!