Can you help me how to interpolate data in the excel table?

Can you help me how to interpolate data in the excel table?(my table on excel look like this)
  • set(handles.total_answer,'String',out);
  • P EL
  • 800 300
  • 750 250
  • 725 175
  • 700 100
My GUI solves power, after that if the answer match on the excel he will give the equivalent row value..my problem now, for example i got result of 705 so the there is not same number in excel.. so my solution it will interpolate the value from 700-725? How do I solve that?

Answers (1)

I'm not sure what an Excel row would look like if it looked like this: "* set(handles.total_answer,'String',out); * P EL * 800 300 * 750 250 * 725 175 * 700 100" What's going on with the set() statment? Is that a string in an Excel cell? What's going on with the asterisks and other character strings (P & EL)???
Anyway, looking at just the numbers 800 300 750 250 725 175 700 100, it looks like 705 could be in there in 5 different places, between 800 & 300, between 300 & 750, between 750 & 250, between 250 & 725, and between 725 and 175. Bottom line, I have no idea what you tried to explain, so just take a look at interp1() or look up interpolation in wikipedia. If that doesn't work, come beck here and explain better.

6 Comments

this is the whole code I made....
a = get(handles.input1_gamma,'String'); %GAMMA
b = get(handles.input2_h,'String'); %H
c = get(handles.input3_q,'String'); %Q
d = get(handles.input4_power,'String'); %POWER
e = get(handles.input5_eout,'String');
out = str2num(b) + str2num(e);
set(handles.total_answer,'String',out);
data = xlsread('table.xlsx')
[m n] = size(data)
k = get(handles.total_answer,'String')
for i = 1 : m
A = data(i); %check xa 1st row then compare value
A = int2str(A);
if strcmp(A,k)
n = i;
score = data(n,2)%compare sa 2nd value
clc; %clear and cmd
set(handles.equalel,'String',score);
else
mHeight = [700 750 800]
mEout = [100:300]
mElevation = out;
outputArea = interp1(mHeight, mEout, mElevation);
set(handles.equalel,'String',outputArea);
end
clc;
end
(my GUI is solving power, after the result my gui will read the excel if they gui result same on the table he will display the equivalent row value such as 800 = 300..if the result is not match he will interpolate the result int GUI..my problem in interpolate it was on fixed set.. what i want is to interpolate the numbers in the excel.. got me sir?)
table is
POWER E
800 300
750 250
725 175
700 100
Looks like easy straightforward interpolation to me. 705 is 1/5th of the way from 700 to 725 so the answer is 1/5th of the way from 100 to 175. You don't even need interp1() - it's just straightforward 9th grade algebra. Do you need the formula?
Yes I really need a formula.. can you help me with my problem?
I was thinking interpolate will solve the problem that's why i came up with that =)
can you give me the formula sir? please?
hmmm 1st column would be 700 up to 800 and the 2nd column would be 100 - 300.. my gui can read excel then if there are match number he will give the equivalent row at 2nd column...
what if answer on GUI not match at 1st column.. so i need interpolation? or just algebra formula?
http://en.wikipedia.org/wiki/Linear_interpolation

Sign in to comment.

Asked:

on 17 Jan 2012

Community Treasure Hunt

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

Start Hunting!