Interpolate between two lines

11 Ansichten (letzte 30 Tage)
Jenny
Jenny am 11 Sep. 2013
Kommentiert: dpb am 8 Mär. 2014
I have data at 5m depth and data at 25m depth. I need to interpolate between these two points to get data at 15m depth.
data5m=[7.0 9.0 6.0 11.0 11.8 11.8 5.0 4.9 5.0 5.5 5.6 5.9 6.0 4.6 4.5 6.5 7.7 5.0 6.4 5.5 5.5 6.2 9.9 11.0] data15m=[5.8 6.0 6.6 5.1 7.1 5.4 7.4 7.4 7.2 7.6 7.7 7.2 8.0 7.6 6.5 7.0 6.8 6.2 5.0 5.2 4.6 6.4 6.3 5.8 ].
How do I interpolate to get values at 15m?
Is it possible to use a logarithmic profile between the two points to interpolate to 15m?
Thank you, Jenny

Akzeptierte Antwort

dpb
dpb am 11 Sep. 2013
Since 10 is midpoint between 5 and 25, linear interpolation would simply be the average. But, in general, interp1 is your friend...
>> interp1([5 25]',y,15)
ans =
6.40 7.50 6.30 8.05 9.45 8.60 6.20 6.15 6.10 6.55 6.65 ...
>> mean(y)
ans =
6.40 7.50 6.30 8.05 9.45 8.60 6.20 6.15 6.10 6.55 6.65 ...
Logarithmically, ...
>> 10.^(interp1([5 25]',log10(y),15))
ans =
Columns 1 through 9
6.3718 7.3485 6.2929 7.4900 9.1531 7.9825 6.0828 6.0216 6.0000
Columns 10 through 18
6.4653 6.5666 6.5177 6.9282 5.9127 5.4083 6.7454 7.2360 5.5678
Columns 19 through 24
5.6569 5.3479 5.0299 6.2992 7.8975 7.9875
>>
  2 Kommentare
jotun
jotun am 8 Mär. 2014
>> interp1([5 25]', y ,15)
Could you define " y " please?
And at the beginning the value 10 should be 15.(it is not effecting the answer)
And also at the question; data15m array should be named data25m i think.
Thank you.
dpb
dpb am 8 Mär. 2014
The 10 was a type -- note that 15 was used
y is just the y data; the OP's data15m. Nothing magic I just used a shorter variable name. And, yes, it looks like OP had a mismatch as well...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by