I'm trying to get this plot to show me a function I can code in desmos, but is giving me the wrong plot in matlab. Any help would be appreciated

3 次查看(过去 30 天)
clc, close all, clear vars
% Pieces of the function
Q = 9.4*10^-6; % C
q = 2.4*10^-5; % C
e = 8.854*10^-12; % C^2/(Nm^2): permittivity constant
F = 0.3; % Force, newtons
R = 0.1; % radius, m
z = -0.1:0.01:0.5;
force = @(z) Q*q.*z/(2*e)*(1-z/sqrt(z.^2 + R^2))-F;
plot(z, force(z), 'g', 'LineWidth', 2);
hold on
yline(0, 'r', 'LineWidth', 2);
grid on
xlabel('Distance (m)','FontSize',14);
ylabel('Force', 'FontSize',14);
title('Force vs Distance, problem 1a')
lgd = legend({'Force/Distance', 'Force at 0.3 N'},'Fontsize', 14, 'LineWidth', 1.1);

采纳的回答

Walter Roberson
Walter Roberson 2024-3-7
clc, close all, clear vars
% Pieces of the function
Q = 9.4*10^-6; % C
q = 2.4*10^-5; % C
e = 8.854*10^-12; % C^2/(Nm^2): permittivity constant
F = 0.3; % Force, newtons
R = 0.1; % radius, m
z = -0.1:0.01:0.5;
force = @(z) Q*q.*z/(2*e).*(1-z./sqrt(z.^2 + R^2))-F;
plot(z, force(z), 'g', 'LineWidth', 2);
hold on
yline(0, 'r', 'LineWidth', 2);
grid on
xlabel('Distance (m)','FontSize',14);
ylabel('Force', 'FontSize',14);
title('Force vs Distance, problem 1a')
lgd = legend({'Force/Distance', 'Force at 0.3 N'},'Fontsize', 14, 'LineWidth', 1.1);

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by