Vectors must be the same length.
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ameyr Rosha
el 30 de Mayo de 2021
Respondida: Star Strider
el 30 de Mayo de 2021
Help!!! im trying to plot a graph. But its always tell me 'Vectors must be the same length.'
h=0.04; %step size
t=0.04:h:0.6; %time
y=[0.1560 0.0125 0.0850 0.2360 0.2450 0.0350 0.5610];%Displacement
v=diff(y)/h; %First derivative of y
a=diff(v)/h; %Second derivative of y
j=diff(a)/h; % Third derivative of y
%plot y vs t
plot(t,y,'LineWidth',2);
grid on
xlim([min(t) max(t)])
xlabel('t')
ylabel('y')
title('Plot of y vs. t')
Error using plot
Vectors must be the same length.
1 comentario
Torsten
el 30 de Mayo de 2021
What is the t vector that corresponds to the displacement vector ? It must have 7 elements.
Respuesta aceptada
Star Strider
el 30 de Mayo de 2021
% h=0.04; %step size
% t=0.04:h:0.6; %time
y=[0.1560 0.0125 0.0850 0.2360 0.2450 0.0350 0.5610];%Displacement
t = linspace(0.04, 0.6, numel(y));
h = t(2)-t(1)
v=gradient(y,h); %First derivative of y
a=gradient(v,h); %Second derivative of y
j=gradient(a,h); % Third derivative of y
%plot y vs t
figure
plot(t,y,'LineWidth',2);
grid on
xlim([min(t) max(t)])
xlabel('t')
ylabel('y')
title('Plot of y vs. t')
.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
