MATLAB Answers

How can I extract a profile from a surface?

조회 수: 20(최근 30일)
Leonardo Colavitti
Leonardo Colavitti 2017년 2월 1일
댓글: Leonardo Colavitti 2017년 2월 23일
Hello everybody, I would like to extract a profile from a surface. My initial matrix is composed by a matrix (18011*3) of Longitude, Latitude and Depth values. Specifically, I'd like a function that in input takes the position of start (A) and end of my profile (B) (xa,ya,xb,yb) and in output return the position of the corresponding z in A and B {e.g. [A,B] = myfunc(xa,ya,xb,yb)}. I am new in matlab and now very desperated ... Someone can help me, please?


Iddo Weiner
Iddo Weiner 2017년 2월 1일
Hi Leonardo, I hope I understood your question properly... Here's my suggestion (I worked with small made-up data):
data = rand([5,5,5]);
xA = 2; xB = 4; yA = 5; yB = 5;
zA = data(xA,yA,:); zB = data(xB,yB,:);
% initiate new arrays and use a loop to lower the dimensions:
low_zA = nan(length(zA),1);
for i = 1:(length(low_zA))
low_zA(i) = zA(1,1,i);
low_zB = nan(length(zB),1);
for i = 1:(length(low_zB))
low_zB(i) = zB(1,1,i);
% now if you want to draw each of the profiles:
hold on
ylabel('Z axis value')
Notice that I have some code duplication here. I'd generalize this example into a function before starting to work with it.
Hope this helps,
  댓글 수: 1
Leonardo Colavitti
Leonardo Colavitti 2017년 2월 2일
Hello Iddo, thank you very much for your answer but I would like something of little different. I have an initial matrix which constitutes a curve (which easily I plot with plot3, mesh and surf). My goal is to write a function that in input has two values in space (xa,ya) and (xb,yb) while in output I would like to see a profile between x values and z(depth) that represents the interception between the curve and the plane y=0... I hope you can help me, anyway Thank you again!

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

Walter Roberson
Walter Roberson 2017년 2월 1일 has it already built in (Image Processing Toolbox)
  댓글 수: 1
Leonardo Colavitti
Leonardo Colavitti 2017년 2월 23일
Thanks for your answer, but it is not exactly what I am looking for. My function is defined by points and I think that 'improfile' evaluates the values of pixels (intensity) along a line in grey scale or RGB colors. Do you have any other idea?

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


Community Treasure Hunt

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

Start Hunting!

Translated by