time series plot on google earth using matlab - matlab

I have three sets of data:
time
longitude
latitude
I would like to plot this on google earth using google earth toolbox for matlab, what i need is when i move the time slider a line should be drawn on google earth.
I tried this
x = [longitude, latitude];
y = time;
kmlStr = ge_plot(x,y);
But an error occured.
On the other hand ge_gplot does not make sense for this.
Is there a way i can do this timeseries plot using google earth toolbox?

Create two vectors: one for x (longitude), one for y (latitude). ge_plot(x,y) will draw a line connecting each pair of (x,y) points in these vectors.
If you want to draw the line as a slider advances, then you need to make use of a callback function. In this function, do ge_plot(x(1:ind), y(1:ind) ) where ind is determined by the "time" value of the slider.

Related

Matlab: How to plot coordinate locations using x markers in a contour map?

I need to plot the locations of 3 treasures on a contour map.The coordinates are in a matrix (3x2) called "treasures", the first column contains the y coordinates, and the second column the x coordinates.
Using an X marker I was asked to plot the treasures locations using a marker size of 15, a line width of 4 and a red color.
How could I do that? the image should look like this
It looks like you need to read a basic tutorial on matlab first before you take on this project.
plotting scattered points can be done in matlab using the command plot. Assuming your treasure locations is x and y (both can be a vector for multiple points), you can plot those using
plot(x,y,'rx','markersize',15)

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

matlab 4D interpolation plot

Here is a sample dataset.
x = linspace(10,20,50);
y = linspace(10,20,50);
z = cos(linspace(0,2*pi,50));
time = linspace(1,60,50);
sci_temp = randi(100,50,1);
x,y,z is position, and sci_temp is temperature data.
I wonder how to draw trajectory over xyz position with sci_temp data.
I try interpolate data, so I get 2D interpolate time vs z with sci_temp plot.
S = TriScatteredInterp(time',z',sci_temp);
[t_mesh z_mesh] = meshgrid(time,z);
tz_mesh = S(t_mesh, z_mesh);
pcolor(t_mesh,z_mesh,tz_mesh)
What I want to get is a 2D (time vs sci_temp) section map on a xyz 3D plot. Like this image.
how to show trajectory over sci_temp in 3D plot?
Is there anyone can help me?
Thanks
First, you are doing your interpolation slightly wrong, you don't want to interpolate over the mesh created by
meshgrid(time,z);
Because it will duplicate values. You want to interpolate over the mesh created by
meshgrid(time,linspace(min(z),max(z),50));
Once you get the interpolated values like:
You can plot them in 3D space with the surface function, you just need to make sure to give x and y coordinates appropriately
surface(repmat(x,50,1),repmat(y,50,1),zmesh,tzmesh)
You can even have more complex paths, for example, same data but y=z
Edit: Also I forgot to mention, I'd suggest you to use scatteredInterpolant instead of TriScatteredInterp. It gives you more control over the interpolation

Matlab - Multiple 2D plots along a 3rd dimension

I'm trying to plot many 2D plots (x,y).
But...
each 2D plot is for a constant z.
So really my data is (x,y,z) but not z(x,y), which I believe are the requirements for using the "surf" command.
Could anyone help with this?
Example,
x = velocity
y = drag
I have multiple runs of y(x) for a constant temperature, z.
I just want to plot each (x,y) along a 3rd axis, temperature z.
Ideally I'd also want some sort of contour between the (x,y) plots so I can show the peaks/troughs etc.
Any help would be great.
If the runs are not independent (there is some trend over multiple runs) then it may make sense to use surf. You then need to construct your data such you have an X,Y, and Z - in this case I'd suggest you use the drag measurements as your Z (height).
Assuming that you have all the drag/velocity data in drag and velocity which are both of size [data points x number of runs]:
% construct matrix of run numbers
runs = repmat(1:numruns, [1, datapoints]);
runs = reshape(runs, datapoints, numruns);
% plot and label
surf(runs,velocity,drag);
xlabel('runs')
ylabel('velocity')
zlabel('drag')

Moving point plot for 2 variable function Matlab

For the function z= 10+pow((x-2),2)+pow((y+5),2), I want to represent in a 3D plot every value of z for each (x,y) pair , with a display delay before each new value of z (like a moving point).
The values for x,y are read from files.
I tried to modify Jacobs code from Creating a point moving along a graph in MATLAB, but I couldn't get it to work for my 2 variable function.
I would like a general solution, because I will also need this plotting for a N-variable function.
Have a look at the following question and see if it answers yours:
animate plot / trajectory in matlab / octave