How do I label each (X, Y) coordinate in a plot on matlab? - matlab

If I have this code
plot(X, Y, 'rx')
How do I add a custom label for each of these (X, Y) coordinates which would display next to the red x on the figure?

Related

How to export a 3D surface (gyroid) into an STL file

How do I export this Matlab code into an STL file for Solidworks and 3D printing?
[x, y, z] = meshgrid (-pi:pi/16:pi); % 3D coordinates defined by x, y, z
v = sin(x).*cos(y)+sin(y).*cos(z)+sin(z).*cos(x); %gyroid formula
t=0.5+0.1*z; % offset from isovalue, affects thickness
v=(v-t).*(v+t); %multiplies one negative offset gyroid and one positive offset gyroid
figure(1)
isosurface (x, y, z, v, 0);
hold on
figure(1)
isocaps(x,y,z,v,0,"below");

shadow an area on contour matlab

I'm tiring to plot contour map like picture is following below , i can plot the contour, but problem is with shadow area on contour . actually i have 4 vector data [x,y,z,k]. x,y area coordinates and z , k are levels .
my code:
sample=xlsread('sample.xlsx');
x=(sample(:,1));
y=(sample(:,2));
z=(sample(:,3));
k=sample(:,4);
N=50;
[X,Y]=meshgrid(linspace(min(x)-0.2, max(x)+0.2, N), linspace(min(y)-0.2, max(y)+0.2, N));
F = scatteredInterpolant(x, y, z);
FF=scatteredInterpolant(x, y, k);
Z= F(X,Y);
ZZ=FF(X,Y);
contour(X,Y,Z,'ShowText','on') %main contour
hold on
???? shadow???
How should do this ?? thanks
If you have the X-Y points of the "shadow area", you can use the fill command (documentation)
fill(X_Area,Y_Area,'b')

Convert columns with x, y, z and velocity coordinates to a picture

I have an array with 4 columns:
x coordinates,
y coordinate,
z coordinate,
and velocity magnitude.
Is there a simple way to convert this data to a heat map?
Thanks.
Try using scatter3:
scatter3(x, y, z, 20, v);
colormap jet

Error in mesh(X,Y,Z) in matlab

This is my code:
load mwe16_2.dat;
x = mwe16_2(:,1); % x contains the 1st column(500 values) of ‘mwe16_2’
y = mwe16_2(:,2); % y contains the 2nd column (500 values)of ‘mwe16_2’
z = mwe16_2(:,3); % z contains the 3rd column(500 values) of ‘mwe16_2’
[X, Y, Z] = meshgrid (x, y, z);
mesh (X, Y, Z)
While running the code it is showing the error:
*Error in plot3_d (line 13) mesh(X,Y,Z) in Matlab*
Can someone say the reason for the error and how to correct it?
[X,Y,Z] = meshgrid(x,y,z) produces three 3D arrays from x, y and z vectors. Now if you take a look at mesh you will see that you are not providing this function with proper input.
If you want to illustrate the set of points defined by three vectors of x, y and z, you can consider using scatter3:
figure; scatter3(x, y, z)

A 3D plot in MATLAB

I have two variables which i sweep, W1 and W3. I made a nested loop of these two variables.
for i=1:size(W1,2)
for j=1:size(W3,2)
d(i,j)=someexpression(W1(i),W3(j))
end
end
I want to do a 3D plot with W1 in the x-axis and W3 in the y-axis and d should be in the z-axis so that I have a 3D plot (or some contour plot).
EDIT: The 3d plot should actually be a surface
You can do the interpolation manually:
x = linspace(W1(1), W1(end), 100);
y = linspace(W2(1), W2(end), 100);
z = interp2(W1, W2, d, x, y);
surf(x, y, z)