Extracting data tips from 3-D figure

1 view (last 30 days)
Tsuwei Tan
Tsuwei Tan on 30 Jul 2019
Commented: Tsuwei Tan on 30 Jul 2019
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]);

Accepted Answer

KSSV
KSSV on 30 Jul 2019
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]

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!