Matrix dimensions must agree.
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Where is problem? please helpp me ;(((
function ptcd_ptqd
clc
clear var1
clear var2
close all
%% NHAP DU LIEU
t = linspace(0,5,6);
%% TINH TOAN TOA DO
x = 3*t.^2-(4/3*t.^3) ; % hoanh do [m]
y = 8*t ; % tung do [m]
dt = diff(t);
dx = diff(x);
dy = diff(y);
%% TINH TOAN VAN TOC
vx = dx./dt ; % thanh phan van toc theo phuong ngang [m/s]
vy = dy./dt ; % thanh phan van toc theo phuong thang dung [m/s]
v = sqrt(vx.^2+vy.^2); % van toc
dt = diff(t);
dvx = diff(vx);
dvy = diff(vy);
%% TINH TOAN GIA TOC
ax = dvx./dt; % thanh phan gia toc theo phuong ngang [m/s^2]
ay = dvy./dt ; % thanh phan gia toc theo phuong thang dung [m/s^2]
a = sqrt(ax.^2+ay.^2); % gia toc
%% FIGURE
figure('name','Toa do','color','white','numbertitle','off');
plot(t,x,'linewidth',2);
xlabel('Thoi gian');
ylabel('Toa do [m]');
figure('name','Van toc','color','white','numbertitle','off');
plot(tv,v,'linewidth',2);
xlabel('Thoi gian');
ylabel('Van toc [m/s]');
figure('name','Gia toc','color','white','numbertitle','off');
plot(ta,a,'linewidth',2);
xlabel('Thoi gian');
ylabel('Gia toc [m/s^2]');
end
0 commentaires
Réponses (1)
Image Analyst
le 23 Déc 2020
dt does not have one element for every element. It has one element for every PAIR of elements. Since all your dt are the same, just do this
dt = t(2) - t(1);
to get the difference between any two t elements (since the spacing is uniform).
0 commentaires
Voir également
Catégories
En savoir plus sur Frequency Transformations 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!