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)
