function y = getValueFromTable(yName, xName, x) [xa, ya] = getTableRow(yName, xName, x, 'first row ') ; if xa==x y = ya ; else [xb, yb] = getTableRow(yName, xName, x, 'second row') ; y = linearInterpolation(xa, xb, ya, yb, x) ; end end function [xRow, yRow] = getTableRow(yName, xName, x, rowNameId) message = sprintf('Go to table T-9 near %s = %.2f, %s => [%s, %s] = ', xName, x, rowNameId, xName, yName) ; values = input(message) ; xRow = values(1) ; yRow = values(2) ; end function y = linearInterpolation(xa, xb, ya, yb, x) y = ya + (x-xa)/(xb-xa)*(yb-ya) ; end