필터 지우기
필터 지우기

Extracting data tips from 3-D figure

조회 수: 1 (최근 30일)
Tsuwei Tan
Tsuwei Tan 2019년 7월 30일
댓글: Tsuwei Tan 2019년 7월 30일
Please download long_lati_depth.mat
And run the code.
May I ask how to automatically extract the data when the line A to B intersecting the isobath line which is one meter increment like [-74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84] ?
The extracted data should be a 3D matrix with selected longitude, latitude and depth.
I am trying to find the water depth change with range from A to B, with one meter increment. Thanks!
clear;clc;close all;figure(1);load('long_lati_depth.mat','long','lati','depth')
contour(long,lati,depth,[-74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84],'ShowText','on')
hold on
% A
plot3(-73.0497,39.0232,0,'ko','LineWidth',5);text(-73.0497,39.0232,'\leftarrow A','Color','red')
% B
plot3(-73.0623,39.0542,0,'ko','LineWidth',5);text(-73.0623,39.0542,'\leftarrow B','Color','red')
images.roi.Line(gca,'Position',[-73.0623 39.0542;-73.0497 39.0232]);

채택된 답변

KSSV
KSSV 2019년 7월 30일
clear;clc;close all;
figure(1);
load('long_lati_depth.mat','long','lati','depth')
contour(long,lati,depth,[-74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84],'ShowText','on')
hold on
% A
A = [-73.0497,39.0232] ;
plot3(-73.0497,39.0232,0,'ko','LineWidth',5);
text(-73.0497,39.0232,'\leftarrow A','Color','red')
% B
B = [-73.0623,39.0542] ;
plot3(-73.0623,39.0542,0,'ko','LineWidth',5);
text(-73.0623,39.0542,'\leftarrow B','Color','red')
% images.roi.Line(gca,'Position',[-73.0623 39.0542;-73.0497 39.0232]);
% Get line for AB
x = [A(1) B(1)] ;
y = [A(2) B(2)] ;
p = polyfit(x,y,1) ;
xi = linspace(x(1),x(2)) ;
yi = polyval(p,xi) ;
plot(xi,yi,'r')
% Get depth for xi,yi
zi = interp2(long,lati,depth,xi,yi) ;
iwant = [xi; yi ;zi]
  댓글 수: 1
Tsuwei Tan
Tsuwei Tan 2019년 7월 30일
Great! Fast and easy! Thank you so much KSSV!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by