How do I make a 3D plot with assigned values?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lieke Pullen
am 7 Jan. 2022
Kommentiert: Lieke Pullen
am 9 Jan. 2022
Hi all,
I am trying to plot a 3D mesh grid based on the x, y and z coordinates and an assigned value. Each coordinate has its own value, and thus I would like to plot the values assigned to that coordinate. My code is the following:
Svalues=readmatrix('s_values.csv');
xs=Svalues(:,1);
ys=Svalues(:,2);
zs=Svalues(:,3);
s=Svalues(:,4);
figure;
points=length(xs);
for n=1:points
scatter3(xs(n),ys(n),zs(n),s(n));
hold on
end
It is probably varily easy, but I do not seem to get it right. Can anybody help me out?
Furthermore, the coordinates are symmetrical in 3D, and I would also like to plot that into a matrix (or so), so that I can multiply it with other matrices. Any tips on how to do that? Thanks in advance!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Jan. 2022
Svalues = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/856420/s_values.csv')
xs=Svalues(:,1);
ys=Svalues(:,2);
zs=Svalues(:,3);
s=Svalues(:,4);
N = 100;
xmin = min(xs); xmax = max(xs);
ymin = min(ys); ymax = max(ys);
zmin = min(zs); zmax = max(zs);
[XQ, YQ, ZQ] = meshgrid(linspace(xmin, xmax, N), linspace(ymin, ymax, N), linspace(zmin, zmax, N));
F = scatteredInterpolant(xs, ys, zs, s);
SQ = F(XQ, YQ, ZQ);
Levels = linspace(min(SQ(:)), max(SQ(:)), 12);
for L = Levels
isosurface(XQ, YQ, ZQ, SQ, L);
end
3 Kommentare
Walter Roberson
am 7 Jan. 2022
Svalues = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/856420/s_values.csv');
xs = Svalues(:,1);
ys = Svalues(:,2);
zs = Svalues(:,3);
s = Svalues(:,4);
N = 100;
xmin = min(xs); xmax = max(xs);
ymin = min(ys); ymax = max(ys);
zmin = min(zs); zmax = max(zs);
[XQ, YQ, ZQ] = meshgrid(linspace(xmin, xmax, N), linspace(ymin, ymax, N), linspace(zmin, zmax, N));
F = scatteredInterpolant(xs, ys, zs, s);
SQ = F(XQ, YQ, ZQ);
Levels = linspace(min(SQ(:)), max(SQ(:)), 12);
Levels = Levels(2:end-1);
M = [
-1 -1 -1;
-1 -1 1;
-1 1 -1;
-1 1 1;
1 -1 -1;
1 -1 1;
1 1 -1;
1 1 1;
];
for L = Levels
for K = 1 : size(M,1)
isosurface(XQ*M(K,1), YQ*M(K,2), ZQ*M(K,3), SQ, L);
end
end
set(findobj(gca, 'type', 'patch'), 'FaceAlpha', 0.3);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

