Question

I have created the following data in MATLAB as an example, using the x and y axes:

t = 1:5    % time in seconds

dxx = [10,8,6,5,4] % speed in x direction
w = trapz(t,dxx)   % distance object in x direction (numerical integration)

dyy = [9,7,6,5,3]  % speed in y direction
c = trapz(t,dyy)   % distance of object in y direction (numerical integration)

How can I plot the vectors dxx(t) vs dyy(t) (the net trajectory at time t), using only this data?

Était-ce utile?

La solution

First I assume you need cumtrapz instead of trapz. For plotting you can use quiver

t = 1:5    % time in seconds

dxx = [10,8,6,5,4] % speed in x direction
w = cumtrapz(t,dxx)   % distance object in x direction (numerical integration)

dyy = [9,7,6,5,3]  % speed in y direction
c = cumtrapz(t,dyy)   % distance of object in y direction (numerical integration)

quiver(w,c,dxx,dyy)

resulting in:

enter image description here

Is it what you are looking for?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top