Combining two surfaces from two files into one surface plot
조회 수: 29(최근 30일)
표시 이전 댓글
댓글: Wesam AlAmiri 2022년 4월 6일
Is there any way to combine two surface plots from diffterent matlab files into one surface plot?
Assuming that the range of X,Y,Z coordinates of the two surfaces are close.
댓글 수: 0
Dave B 2022년 4월 6일
편집: Dave B 2022년 4월 6일
Do you mean two different .fig files?
You can generally find objects that live in an axes with findobj, which is good for looking for an object of a specific type. You can reparent those objects by setting the Parent (e.g. to a new axes, or from one old axes into another):L
This bit creates a couple of example surfaces
The bit below opens the figures
f1 = openfig('foo1.fig');
f2 = openfig('foo2.fig');
The final section finds the surfc and copies them into a new axes:
s1 = findobj(f1,'Type','surf');
s2 = findobj(f2,'Type','surf');
ax=axes; % the new target for the old surfs
copyobj(s1, ax) % or s1.Parent = ax; to move it
copyobj(s2, ax); % or s2.Parent = ax; to move it
% note that the new axes won't inherit the configuration of the old axes
% (e.g. the 3-d view), but see below for an alternative.
% or: just do copyobj(s1,s1.Parent) or s2.Parent=s1.Parent if
% you want to copy/move the second surface into the same axes
% as the first, preserving the view and other axes characteristics
댓글 수: 3
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!