Clear Filters
Clear Filters

How do i contruct 3D Data like in my example

2 views (last 30 days)
x,y are the coordinates of the circle points.
z is the brightness of the points.
so i have this
I want to create something like this (blue lines)
How can i do that? I tried some things with meshgrid, surf() and i tried to use scatteredInterpolant() too but i cant really figure it out.
Anyone know some useful keywords or functions?
Here is the code used to generate the plots...
A = readmatrix('simucoord.txt')
x = A(:,1)
y = A(:,2)
z = A(:,3)
Radii = floor(A(:,4))
%plotting the data
plot3(x,y,z, 'r*')
%%%IGNORE EVERYTHING BELOW%%%
x_center = 1.2533*10^3; %from simulation_23072020.mlx
y_center = 0;
clear x y z
%Plotting the data with the help of the Radii
th = 0:pi/50:pi;
x{1} = Radii(1) .* cos(th)-x_center;
y{1} = Radii(1) .* sin(th);
z{1} = ones(length(x{1}),1)*4;
x{2} = Radii(25) .* cos(th)-x_center;
y{2} = Radii(25) .* sin(th);
z{2} = ones(length(x{1}),1)*4;
x{3} = Radii(77) .* cos(th)-x_center;
y{3} = Radii(77) .* sin(th);
z{3} = ones(length(x{1}),1)*4
x{4} = Radii(99) .* cos(th)-x_center;
y{4} = Radii(99) .* sin(th);
z{4} = ones(length(x{1}),1)*3
x{5} = Radii(133) .* cos(th)-x_center;
y{5} = Radii(133) .* sin(th);
z{5} = ones(length(x{1}),1)*3
plot3(x{1}, y{1}, z{1}, x{2}, y{2}, z{2}, x{3}, y{3}, z{3}, x{4}, y{4}, z{4}, x{5}, y{5}, z{5})
xlim([0 1000])
ylim([0 1000])
  7 Comments
Hoschang Noori
Hoschang Noori on 24 Jul 2020
Edited: Hoschang Noori on 24 Jul 2020
Oh okay. I want to generate more circle segments on the blue lines. In the end it should look like the main circle segments are "fading away" (z gets lower).
A little bit like what scatteredInterpolant() seems to do.
The end goal is to make a matrix out of the plot, similiar to this one (without the noise)
I hope this makes it clearer now...
Hoschang Noori
Hoschang Noori on 24 Jul 2020
I think i got a good idea how to handle this. I will use cylinder.
A = readmatrix('simucoord.txt');
%Generating Cylinder (just for one circle for now).
Radii = floor(A(:,4));
t = 0:pi/10:pi;
cols = length(t);
r = Radii(1) - 1000*cos(t);
[X,Y,Z] = cylinder(r,100);
%Save positive values, reshape matrices
X = X(X>0); X = reshape(X,cols,[]);
Y = Y(X>0); Y = reshape(Y,cols,[]);
Z = Z(X>0); Z = reshape(Z,cols,[]);
%show surface
surf(X,Y,Z)
%plot circles above a specific value.
ax = 0.6
x_saved = X(Z>ax)
y_saved = Y(Z>ax)
z_saved = Z(Z>ax)
plot3(x_saved,y_saved,z_saved, 'r*')
view([0 90.000])
%Transform the plot into a matrix....

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!