Filter löschen
Filter löschen

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 Ansichten (letzte 30 Tage)
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);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Mär. 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);

Weitere Antworten (0)

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by