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?

 채택된 답변

KSSV
KSSV 2017년 1월 31일
편집: KSSV 2017년 1월 31일

0 개 추천

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
KSSV
KSSV 2017년 1월 31일
편집: KSSV 2017년 1월 31일
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
KSSV
KSSV 2017년 1월 31일
편집: KSSV 2017년 1월 31일
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개)

카테고리

질문:

2017년 1월 31일

댓글:

2017년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by