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

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

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");

How to display a 2-D matrix using surf or mesh?

Let's say I have a matrix A, how can I display it with surf or mesh that X-Y axies are the index of elements(e.g. i,j) and the Z value is the values in A(i,j)?
You can just pass it directly to surf and it will automatically use the indices as the x and y coordinates
data = rand(10)
surf(data);
surf(Z) creates a three-dimensional shaded surface from the z components in matrix Z, using x = 1:n and y = 1:m, where [m,n] = size(Z). The height, Z, is a single-valued function defined over a geometrically rectangular grid. Z specifies the color data, as well as surface height, so color is proportional to surface height. The values in Z can be numeric or datetime or duration values.

How to get the pixel indices from the world coordinates with a calibrated camera in matlab

I have calibrated my camera and I have now cameraParams, rotation and translation matrices (R ,t)
I know that there is a way to get the world coordinates from the pixel indices by the function "pointsToWorld(__)" but I want to do the otherwise , I can't find anything about that in the Matlab help !
So I don't know what to do, any suggestions?
Currently you have to do that yourself. If you have R and t, you can use the cameraMatrix function to compute the camera projection matrix P. Then you can compute the projection of a world point into the image as follows:
P = cameraMatrix(cameraParams, R, t);
p = [X, Y, Z, 1] * P;
x = p(1) / p(3);
y = p(2) / p(3);
X, Y, and Z are the world coordinates. x and y are the image coordinates in pixels.

How to fit a 3D surface to geographic coordinates?

Good day everyone;
I have a M*N matrix and I have two coordinate vectors X and Y, where X has the length of M and Y has the length of N but they have different values because M is an array index and X is a Latitude coordinate, for example
M=linespace(0,1000,1000) and X=linespace(-31.291666,51.958332,1000) and similar case for N and Y.
I want to know if there is a way to plot the same data in M * N in a figure surface figure with axis X*Y in matlab?
Thanks a lot in advance!
Do you mean:
[a,b] = meshgrid(x,y);
% z is your 100x1000 matrix
mesh(a,b,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)