KatyB
KatyB

Reputation: 3990

find values from a given array

I have some temperature measurements that are recorded throughout a water column:

depth = 0.2211:0.26:26;
temp = 1 + (30-1)*(rand(1,length(depth)));

where the depth is not continuous. I would like to create a profile of the temperature at depth increments of 0.5 m. To achieve this I firstly create an array of evenly spaced points from the minimum to the maximum depths of the measurements:

newD = min(depth):0.5:max(depth);

Next I would like to obtain the temperature from 'temp' at each of these new depths, how can I do this?

Upvotes: 0

Views: 78

Answers (1)

High Performance Mark
High Performance Mark

Reputation: 78344

Evaluate

newTemp = interp1(depth,temp,newD)

You may want to experiment the with 4th input to interp1, check the documentation.

Upvotes: 2

Related Questions