How to create cross-section from 3d dimensional surface?
显示 更早的评论
I transported the simulated surface's data as three (20x20) matrices X,Y,Z. So, I have a 3D plot that's generated by 3 (20x20) matrices X,Y,Z. I want to plot the YZ curve (cross section) at specified X. Moreover, the dimension of surface is really important to me, and I do not want to miss my surface feature or profile by interpolation?
采纳的回答
You define your required x values and the respective y values, use interpolation (interp2).
Read about interp2 .
12 个评论
Thanks KSSV for your attention x,y,z are three 20*20 matrices. I defined the Y and Z values for meshgrid and desired X's. Then, I tried to get V=X,Y,Z; but the (interp2) Vq = interp2(X,Y,V,Xq,Yq) did not work. can you help me with more details?
[X,Y,Z] = peaks(20);
%
x0 = min(X(:)) ; x1 = max(X(:)) ;
yo = min(Y(:)) ; y1 = max(Y(:)) ;
% interpolation
xi = zeros(1,20) ;
yi = Y(:,1) ;
zi = zeros(size(xi)) ;
for i = 1:length(xi)
zi(i) = interp2(X,Y,Z,xi(i),yi(i)) ;
end
surf(X,Y,Z) ;
hold on
plot3(xi,yi,zi,'.-r') ;
There is a problem about my surface (yellow). It consists of 400 points with different distance. It has not continious meshgrid. In fact, blue surface doesn't cut the yellow one in positions where fit by 400 points positions. I attach the pic to make it sence.
Doesn't matter.....it will work. You attach your data and show me where you want to extract the data.
I attach my matrices. I want to get YZ curves for different X (e.g. YZ curve for X=-5.4) Thanks
load data.mat ;
surf(X,Y,Z) ;
%
x0 = min(X(:)) ; x1 = max(X(:)) ;
y0 = min(Y(:)) ; y1 = max(Y(:)) ;
%
N = 20 ;
xi = -5.4013*ones(1,N) ;
% yi = linspace(1.6496,1.7752,N) ;
yi = linspace(y0,y1,N) ;
zi = zeros(size(xi)) ;
P = [X(:),Y(:)] ; V = Z(:) ;
F = scatteredInterpolant(P,V) ;
F.Method = 'natural';
F.ExtrapolationMethod = 'none' ;
% Take points lying insuide the region
pq = [xi',yi'] ;
Vq = F(pq) ;
zi = Vq ;
hold on
plot3(xi,yi,zi,'.-r')
Thanks KSSV Your attention is highly appreciated
Does it solve your purpose?
I made few changes to the above code, you may have a look now. Earlier you had to specify y values for yi, now it is not needed. You may specify your required xi value and proceed.
The upper point well match with surface. There is a mismatch for first node. Is there any way to fit the nodes with surface by high accuracy. Anyway, your help regarding above code is really great.
It can be done, but depends on how accurate your xi,yi belong to X,Y
Hi I tried this code for my whole surface (23x110 matrix). It showed the misconsistency because of different degree of linearity. Is it possible to increase accuracy with using mesh grid between elements. I attach the image to show you problem. Thanks
I attach matrixes to make it sence.
更多回答(0 个)
类别
在 帮助中心 和 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!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
