Lines on 3D surface plot
10 次查看(过去 30 天)
显示 更早的评论
Hello, I have the following example (see below) of a data that I am using to plot a 3D surface. What I would like to do is to show on my surface the intersection lines of horizontal planes parallel to xy plane with my surface. These parallel planes could be for example at z= 210, z=220, z=230, z=240 etc (intervals could be regular or not). Could you please let me know whether I can do this and how? The data and what I have done so far is here:
X =[
0 0 0 0 0 0 0 0 0 0
0.0357 0.0357 0.0358 0.0358 0.0359 0.0359 0.0359 0.0360 0.0360 0.0360
0.0714 0.0715 0.0716 0.0716 0.0717 0.0718 0.0719 0.0719 0.0720 0.0721
0.1071 0.1072 0.1074 0.1075 0.1076 0.1077 0.1078 0.1079 0.1080 0.1081
0.1429 0.1430 0.1431 0.1433 0.1434 0.1436 0.1437 0.1439 0.1440 0.1441];
Y=[
3.5714 3.5750 3.5786 3.5821 3.5857 3.5893 3.5929 3.5964 3.6000 3.6036
3.5357 3.5392 3.5428 3.5463 3.5499 3.5534 3.5569 3.5605 3.5640 3.5675
3.5000 3.5035 3.5070 3.5105 3.5140 3.5175 3.5210 3.5245 3.5280 3.5315
3.4643 3.4677 3.4712 3.4747 3.4781 3.4816 3.4851 3.4885 3.4920 3.4955
3.4286 3.4320 3.4354 3.4389 3.4423 3.4457 3.4491 3.4526 3.4560 3.4594];
Z =[
276.7398 270.9391 265.1383 259.3376 253.5368 247.7361 241.9354 236.1346 230.3339 224.5331
272.3587 266.5536 260.7484 254.9433 249.1382 243.3331 237.5279 231.7228 225.9177 220.2644
267.9776 262.1680 256.3585 250.5490 244.7395 238.9300 233.1205 227.3110 221.5015 216.3515
263.5964 257.7825 251.9686 246.1548 240.3409 234.5270 228.7131 222.8992 217.0853 212.4386
259.2153 253.3970 247.5788 241.7605 235.9422 230.1240 224.3057 218.4874 212.6691 208.5257];
figure
surf(X,Y,Z)
s=surf(X,Y,Z,'EdgeColor','none')
xlabel('Wi');
ylabel('So');
zlabel('SD');
%%Extract X,Y and Z data from surface plot
x=s.XData;
y=s.YData;
z=s.ZData;
Thanks. K.
0 个评论
采纳的回答
Star Strider
2017-7-12
I am not certain exactly what you want.
This should at least get you started:
figure
surf(X,Y,Z)
s=surf(X,Y,Z,'EdgeColor','none')
hold on
for k1 = 210:10:270
surf(X, Y, k1*ones(size(Z)), 'FaceAlpha',0.5, 'EdgeColor',[1 1 1 ]*0.8)
end
hold off
It simply loops, creating a horizontal plane of ones at each value of ‘k1’.
If you want a larger plane, you will have to define new ‘X’ and ‘Y’ matrices for it. The ‘Z’ matrix defining the plane would then be a ones matrix the same size as those matrices.
3 个评论
Star Strider
2017-7-17
The contour3 function will do what I believe you want:
figure
surf(X,Y,Z,'EdgeColor','none')
hold on
contour3(X, Y, Z, [ 210:10:270], 'LineWidth',1, 'Color','k')
hold off
Experiment with 'LineWidth' and 'Color' to get the result you want.
Akhil Kallepalli
2017-10-19
If you had an image file where X, Y are the coordinates of the pixel and Z is the value of the pixel, how would this implementation change?
更多回答(1 个)
John BG
2017-8-7
Hi Katerina
I have answered your surface 'sectioning' with vertical planes answering your other question.
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG
1 个评论
Jan
2017-10-20
This message contains only a link to a completely unrelated thread of another user, 4 times the name of the author and begging for points.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!