Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


dpb
Posts:
9,331
Registered:
6/7/07


Re: Selecting specific part of matrix through interpolation
Posted:
Feb 13, 2013 2:24 PM


On 2/12/2013 5:10 PM, James Smith wrote: > I have a matrix of amplitudes, which correspond to distance on the x > axis and time on the y axis. I need to create an interpolated line > between a point on the x axis and a point on the y axis, and then remove > everything above this line. For example I have the amplitudes, with time > in the y direction and distance in the x. I want to remove from (1,5) > (the top 5), to (4,1). > > 1 2 3 4 5 6 7 8 9 > 2 3 4 5 6 7 8 9 0 > 3 4 5 6 7 8 9 0 1 > 4 5 6 7 8 9 0 1 2 > 5 6 7 8 9 0 1 2 3 > > Remove: > 1 2 3 4 5 > 2 3 4 5 > 3 4 5 > 4 > Whilst interpolating along the line between the points (1,5) and (4,1). > I have tried using the interp2 function but with no luck. Any > help/advice would be very much appreciated, thanks.
Look at contourc
Given the above
contourc(x,[5,5])
will return a 2row array the first six columns of which will be
5 5 4 3 2 1 5 1 2 3 4 5
where the first column is the contour level requested (5) while the remainder in the first row is the column the contour passes thru (x) while the second is the row (y) of the (x,y) point pairs. You can use these pairs as the intersection points of your selection process.
If the data aren't even so the values aren't integers, you can either fix() or round() depending on which way you want the truncation to happen...
doc contourc % takes some perusing to grasp but think it's what u asked




