plot points as a trajectory of tracking from video - matlab

I think this is very easy question for some of you , but I do not have any experience in Matlab !
I am tracking a point in all the frames in video. now I want to plot this points to show the trajectory
I have (x,y) for the points in all frames
how can I plot this ?
thanks

If you have coordinates x and y, and a frame number t, then plot3 or scatter3 can be useful. The latter allows you to color the points according to the frame number, so that if you rotate it that you only see the xy-plane, you can still distinguish the advancement of time.
Thus:
scatter3(x,y,t,[],t)
should do the trick.

Related

Contour coordinates

I don't know if this is possible, but I would like to be able to plot contour lines in a given latitude and longitude.
I have an ocean model that gives me the currents in direction u and v at location x (longitude) and y(latitude).
Using the quiver function (quiver(x,y,u,v)) and the following code, I managed to map the currents in the Gulf of Lions.
Step=8 %Only use 1 in 8 data point so the arrows don't overlap too much
figure
q=quiver(lonu(1:Step:681,1:Step:711),latu(1:Step:681,1:Step:711),U,V,0)
As you can see, the model is more detailed close to the coast, because it uses the following grid:
Source: Briton, Florence, et al. "High‐resolution modelling of ocean circulation can reveal retention spots important for biodiversity conservation." Aquatic Conservation: Marine and Freshwater Ecosystems 28.4 (2018): 882-893.
The problem with this is that when I try to use contour or contourf it completely loses the shape of the gulf of Lions due to the choice of grid:
figure
contourf(sqrt(U.^2+V.^2))%The vector of the current is X=sqrt(U^2+V^2) see pythagoras
colorbar
So eventually, I would like to be able to indicate the strength of the current using contourf while indicating the direction using quiver. So how do I reshape the picture given by contourf into something realistic using coordinates?
I checked question Matlab 2D contour using X-Y coordinate data but I don't understand how to use the proposed function.
You suddenly decided to avoid imputing the data that gives the shape, X and Y input parameters.
contourf(lonu(1:Step:681,1:Step:711),latu(1:Step:681,1:Step:711),sqrt(U.^2+V.^2))%The vector of the current is X=sqrt(U^2+V^2) see pythagoras

Changing the plot position of z-axis

I wanted to change the position of z-axis in a 3d graph. I tried to do using graph properties but it does not work, Matlab has this option in 2D plot in axis properties window in the graph, but it does not work in 3d plots. Currently,the plot is at z=0 and I wanted to the position to z=6. Attached is the sketch where I need to change the position of the curve plot (red) from z=0 to z6. I appreciate if there is any solution/suggestion regarding this issue. Thank you.
sketch
Regards,
Alishah
A very simple solution for this question is that convert z in your formula to z-6. You know it from mathematics, It will shift a curve, 6 unit .
If you want to change in right or left, you plus or minus.

Matlab plot polygon from sensordata

I have an array of different length measurements to the walls of an arbitrarily shaped box from a point. They are taken during a 360 degree rotation and I also have a degree measurement.
Distance(1:k); % distance to wall of arbitrarily shaped box during a rotation
Degree(1:k); % degrees rotated from first measurement
Time(1:k); % time passed since first measurement
How can I used distance and Time/Distance to plot a shape that would look like the shape of the box? I tried the convhull function, wondering if there are better options.
Would this do the trick?
Rads=Degrees*(2*pi/360);
X=Distance.*cos(Rads);
Y=Distance.*sin(Rads);
plot(X,Y);

Visualize 3D data in MATLAB

I have data on the form (x, y, z, v), in other words three spatial coordinates and one velocity magnitude. I would like to plot this in 3D, where the velocity magnitude is shown using color.
What is the best way to do this in MATLAB?
I assume you have trajectory data, so that your spatial coordinates represent the trajectory through space of one or more particles. In that case:
Have a look at quiver3 or coneplot.
If you want colored arrows, then have a look at quiver3d or quiverc (2D only) on the File Exchange.
If you only have 3 spatial coordinates and speed (= velocity magnitude), then your best bet is scatter3.
I could go on, but could you give me a bit more detail on what you want exactly?
Have you tried surf(x,y,z,v)?

plot a 3d point in MatLab

I'm trying to plot just one point in any coordinate system: Cartesian, cylindrical or spherical.
I tried plot3(1,1,1) with many values but just shows a tiny point in the same location for all values! I tried surf(X,Y,Z) as well but matlab said: Z must be a matrix, not a scalar or vector.
How about this?
plot3(1,1,1,'.');
grid on
You did try it, but then again, that is exactly what it does!
Something like
scatter3(x,y,z1,720,'g','fill')
will make opaque green spheres of 720 size around all the points listed in the vectors x,y,z1.