Axis change - Is it possible to get the data of the new plot?

조회 수: 5 (최근 30일)
Thalles Leite
Thalles Leite 2016년 8월 5일
댓글: DGM 2025년 7월 14일
Hi,
I have a plot, for example, a surface of a sphere, and I'm changing the axis to view a semi-sphere.
Is it possible to get the data of this new plot?
Thanks

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 5일
편집: Azzi Abdelmalek 2016년 8월 5일
Changing the view will not change your data. If you want to get your data from the plot
plot(1:10)
h=findobj('type','line')
x=get(h,'Xdata')
y=get(h,'Ydata')
  댓글 수: 4
Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 22일
If that s what you need then accept the answer.
DGM
DGM 2025년 7월 14일
In order to get things from a surface object, you need to query the surface object, not the figure.
% an example
Z = peaks(10);
hs = surf(Z);
zfromsurf = hs.ZData
zfromsurf = 10×10
0.0001 0.0013 0.0053 -0.0299 -0.1809 -0.2465 -0.1100 -0.0168 -0.0008 -0.0000 0.0005 0.0089 0.0259 -0.3673 -1.8670 -2.4736 -1.0866 -0.1602 -0.0067 0.0000 0.0004 0.0214 0.1739 -0.3147 -4.0919 -6.4101 -2.7589 -0.2779 0.0131 0.0020 -0.0088 -0.0871 0.0364 1.8559 1.4995 -2.2171 -0.2729 0.8368 0.2016 0.0130 -0.0308 -0.4313 -1.7334 -0.1148 3.0731 0.4444 2.6145 2.4410 0.4877 0.0301 -0.0336 -0.4990 -2.3552 -2.1722 0.8856 -0.0531 2.6416 2.4064 0.4771 0.0294 -0.0137 -0.1967 -0.8083 0.2289 3.3983 3.1955 2.4338 1.2129 0.2108 0.0125 -0.0014 -0.0017 0.3189 2.7414 7.1622 7.1361 3.1242 0.6633 0.0674 0.0030 0.0002 0.0104 0.1733 1.0852 2.6741 2.6725 1.1119 0.1973 0.0152 0.0005 0.0000 0.0012 0.0183 0.1099 0.2684 0.2683 0.1107 0.0190 0.0014 0.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Probably wasn't relevant, but for tools like fsurf() or fimplicit(), changing the view will change the data stored in the object.
% an example
hfs = fsurf(@(x,y) 5*besselj(1,hypot(x,y)));
axis equal
% for comparison
axis([-5 5, -5 5, -2 3])
drawnow
size(hfs.ZData)
ans = 1×2
1 4865
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% changing the view changes the data
axis([-4 4, -4 4, 0 3])
drawnow
size(hfs.ZData)
ans = 1×2
1 3527
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by