Effacer les filtres
Effacer les filtres

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 vues (au cours des 30 derniers jours)
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);

Réponse acceptée

Walter Roberson
Walter Roberson le 7 Mar 2024
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);

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by