MATLAB Answers

What would be a best interpolation method to get test data for a specific temperature?

1 view (last 30 days)
Jason Burke
Jason Burke on 5 May 2021
Edited: Jason Burke on 6 May 2021
I have 4 columns of test data (Temp, X, Y, Z). I want to create slices of data (X,Y,Z) for temperatures not collected (0, 40, 100). Each temperature would create a 3d dataset that I would want to graph as a surface. My data does not have the exact temperatures so how can I interpolate the data to get the data I am after?
My data is for each temp (-20, 60, 120, 160), X varried from 0 to 1 and Y varried from 1000 to 10000 and Z was measured. I would like to know how I can create the X, Y and Z data for different temperatures with X and Y varrying the same way.
Also for each temperature, X and Y do not varry the same. They are not gridded, One test run X might be 0.05, 0.34, 0.68 etc... whereas the next time it might be 0.02, 0.28, 0.57 etc...

Answers (1)

Star Strider
Star Strider on 5 May 2021
I would just use interp1
TestData = sortrows(randi([0 200], 15, 4),1)
TestData = 15×4
15 148 72 99 40 97 95 190 43 162 43 162 57 107 19 197 66 145 46 174 81 119 150 111 82 7 164 12 84 57 200 155 95 190 137 89 105 2 123 49
InterpTemps = [0 40 100];
Interp_234 = interp1(TestData(:,1), TestData(:,2:4), InterpTemps, 'linear','extrap')
Interp_234 = 3×3
178.6000 58.2000 44.4000 97.0000 95.0000 190.0000 96.0000 130.0000 69.0000
Result = [InterpTemps(:) Interp_234]
Result = 3×4
0 178.6000 58.2000 44.4000 40.0000 97.0000 95.0000 190.0000 100.0000 96.0000 130.0000 69.0000
.
  1 Comment
Jason Burke
Jason Burke on 6 May 2021
Thanks for this. I won't have just one data row for each temperature. There will be many. I tried this and got an error saying the grid vectors must contain unique points.

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!