Interpolation based on three arrays. Problem: entering values for two parameters to get a third gives me the nearest input data values (no interpolation).
Show older comments
I have measured temperature, pressure, and volume of something and now have a file where there are three columns: T, P, and V. Each row gives me values that go together. For example:
S P V
90 475 1.0
40 200 1.06
20 200 0.84
40 70 1.02
10 70 0.91
I want to to do calculations where I can enter any S and P and get a V. Linear interpolation would be fine. I'm not experienced in statistics, so in case I'm not using the term correctly, what I mean is that I am fine with (for example) entering a S of 30, a P of 200, and having a V that falls halfway between 1.06 and 0.84.
I found a similar question from someone else and copied the answer:
However, there must be something I don't understand because I'm not getting any interpolation. What I mean is, if I enter any S and P, I'm ending up with a V that corresponds to the nearest S and P values that are record in my measurements. Is it that this is what SHOULD happen because I have used "nearest" as a specification? What could I do instead?
S = [90 40 20 40 10];
P = [475 200 200 70 70];
V= [1.0 1.06 0.84 1.02 0.91];
if true
a = S, P, V,'nearest');
pnt1 = a(80,100)
end
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!