How to interpolate column and row?
5 views (last 30 days)
Show older comments
Anita Fitriani
on 20 Mar 2020
Commented: Aditya Gandhi
on 1 Jul 2021
How can I get the value below the 'Year' row, if my G-value is 2.5 and the year is 4.17 and 4.58?
I mean, I have to interpolate the G-values between 2.4 and 2.6, also I have to interpolate the Year between 2 and 5.
Thanks before.
0 Comments
Accepted Answer
Stephen23
on 20 Mar 2020
Edited: Stephen23
on 23 Mar 2020
>> Y = [1.0101,1.25,2,5,10,25,50,100];
>> G = [3,2.8,2.6,2.4,2.2,2,1.8,1.6,1.4,1.2,1,0.8,0.6,0.4,0.2,0,-0.2,-0.4,-0.6,-0.8,-1,-1.2,-1.4,-1.6,-1.8,-2,-2.2,-2.4,-2.6,-2.8,-3];
>> M = [-0.667,-0.636,-0.396,0.42,1.18,2.278,3.152,4.051;-0.714,-0.666,-0.384,0.46,1.21,2.275,3.114,3.973;-0.769,-0.696,-0.368,0.499,1.238,2.267,3.071,2.889;-0.832,-0.725,-0.351,0.537,1.262,2.256,3.023,3.8;-0.905,-0.752,-0.33,0.574,1.284,2.24,2.97,3.705;-0.99,-0.777,-0.307,0.609,1.302,2.219,2.192,3.605;-1.087,-0.799,-0.282,0.643,1.318,2.193,2.848,3.499;-1.197,-0.817,-0.254,0.675,1.329,2.163,2.78,3.388;-1.318,-0.832,-0.225,0.705,1.337,2.128,2.706,3.271;-1.449,-0.844,-0.195,0.732,1.34,2.087,2.626,3.149;-1.588,-0.852,-0.164,0.758,1.34,2.043,2.542,3.022;-1.733,-0.856,-0.132,0.78,1.336,1.993,2.453,2.891;-1.88,-0.857,-0.099,0.8,1.328,1.939,2.359,2.755;-2.029,-0.855,-0.066,0.816,1.317,1.88,2.261,2.615;-2.178,-0.85,-0.033,0.83,1.301,1.818,2.159,2.472;-2.326,-0.842,0,0.842,1.282,1.751,2.051,2.326;-2.472,-0.83,0.033,0.85,1.258,1.68,1.945,2.178;-2.271,-0.816,0.066,0.855,1.231,1.606,1.834,2.029;-2.388,-0.8,0.099,0.857,1.2,1.528,1.72,1.88;-3.499,-0.78,0.132,0.856,1.166,1.448,1.606,1.733;-3.605,-0.758,0.164,0.852,1.128,1.366,1.492,1.588;-3.705,-0.732,0.195,0.844,1.086,1.282,1.379,1.449;-3.8,-0.705,0.225,0.832,1.041,1.198,1.27,1.318;-3.889,-0.675,0.254,0.817,0.994,1.116,1.166,1.197;-3.449,-0.643,0.282,0.799,0.945,1.035,1.069,1.087;-3.605,-0.609,0.307,0.777,0.895,0.959,0.98,0.99;-3.705,-0.574,0.33,0.752,0.844,0.888,0.9,0.905;-3.8,-0.537,0.351,0.725,0.795,0.823,0.83,0.832;-3.889,-0.49,0.368,0.696,0.747,0.764,0.768,0.769;-3.973,-0.469,0.384,0.666,0.702,0.712,0.714,0.714;-7.051,-0.42,0.396,0.636,0.66,0.666,0.666,0.667];
>> Yout = [4.17,4.58];
>> Gout = 2.5;
>> Mout = interp2(Y,G,M,Yout,Gout)
Mout =
0.27522 0.39515
And checking:
>> surf(Y,G,M)
>> hold on
>> plot3(Yout,[Gout,Gout],0.1+Mout,'*r')
>> view(-123,45)
8 Comments
Stephen23
on 1 Jul 2021
@Aditya Gandhi: ask a new question in a new thread, including your example data.
Aditya Gandhi
on 1 Jul 2021
I have created a new question as advised. Please help me correct the code.https://in.mathworks.com/matlabcentral/answers/869498-how-to-interpolate-for-increasing-decreasing-type-of-data-set?s_tid=srchtitle
More Answers (0)
See Also
Categories
Find more on Parallel Computing Fundamentals 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!