Error using plot3 not enough input arguments
Afficher commentaires plus anciens
Hi all,
When I am trying to plot my dots on a 3D plane I get an error with plot3 telling me there are not enough input arguments.
I do not understand why this occurs since I am giving the x,y,z coordinates and the time values into the plot3 command.
Error using plot3
Not enough input arguments.
Error in bugs (line 28)
plot3(i_1, j_1, k_1, tspan)
Here is my code that leads to this error:
clc, clear, clear all
ti=0;
tf=1000;
tspan= linspace(ti,tf,1000000);
f0 = [0; 0; 0; 1; 2; 0; 1; 0; 3; 0; 2; 3];
[t, f] = ode45(@g, tspan, f0);
%Trajectories are done in 3 coordinates x,y,z
i_1=(f(:,1)); %Trajectory of bug 1
j_1=(f(:,2));
k_1=(f(:,3));
i_2=(f(:,4)); %Trajectory of bug 2
j_2=(f(:,5));
k_2=(f(:,6));
i_3=(f(:,7)); %Trajectory of bug 3
j_3=(f(:,8));
k_3=(f(:,9));
i_4=(f(:,10));
j_4=(f(:,11));
k_4=(f(:,12));
figure
hold on
plot3(i_1, j_1, k_1, tspan)
plot3(i_2, j_2, k_2, tspan)
plot3(i_3, j_3, k_3, tspan)
plot3(i_4, j_4, k_4, tspan)
title('test')
xlabel('x')
ylabel('y')
zlabel('z')
function dxdt = g(t,f)
a = sqrt((f(2)-f(1))^2 + (f(6)-f(5))^2 + (f(10)-f(9))^2);
b = sqrt((f(3)-f(2))^2 + (f(7)-f(6))^2 + (f(11)-f(10))^2);
c = sqrt((f(4)-f(3))^2 + (f(8)-f(7))^2 + (f(12)-f(11))^2);
d = sqrt((f(1)-f(4))^2 + (f(5)-f(8))^2 + (f(9) -f(12))^2);
dxdt = [ ...
(f(2) - f(1)) / a;
(f(6) - f(5)) / a;
(f(10) - f(9)) / a;
(f(3) - f(2)) / b;
(f(7) - f(6)) / b;
(f(11) - f(10)) / b;
(f(4) - f(3)) / c;
(f(8) - f(7)) / c;
(f(12) - f(11)) / c;
(f(1) - f(4)) / d;
(f(5) - f(8)) / d;
(f(9) - f(12)) / d];
end
Thank you
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Line Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!