Vectors must be the same length.
조회 수: 15 (최근 30일)
이전 댓글 표시
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
Torsten
2021년 5월 30일
What is the t vector that corresponds to the displacement vector ? It must have 7 elements.
채택된 답변
Star Strider
2021년 5월 30일
% 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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
