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.
KSSV
2017 年 1 月 31 日
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.
KSSV
2017 年 1 月 31 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
