# Homework Help: MATLAB - interp1 Issue

1. Jul 15, 2011

### GreenPrint

RESOLVED

1. The problem statement, all variables and given/known data
Hi,

Code (Text):
>>v=[1;2;3;4;5;6];
P=[2494 4157;1247 2078;831 1386;623 1039;499 831;416 693];
[P_300,P_500]=interp1(v,P,5.2,'linear')

Error in ==> interp1 at 79
xOffset = 1;

??? Output argument "varargout{2}" (and maybe others) not assigned during call to "C:\Program
Files\MATLAB2\R2011a\toolbox\matlab\polyfun\interp1.m>interp1".
I don't understand why I'm getting this error. I'm trying to assign the two values equal to variables. The code runs fine when I try not to assign the values to variables but I would like to assign the values to variables. I don't see what I'm doing wrong.

Code (Text):
>> v=[1;2;3;4;5;6];
P=[2494 4157;1247 2078;831 1386;623 1039;499 831;416 693];
interp1(v,P,5.2,'linear')

ans =

482.4000  803.4000

2. Relevant equations

3. The attempt at a solution

Last edited: Jul 15, 2011
2. Jul 19, 2011

You get multiple outputs in a single vector, not [out0, out1, ...] = interp1(...)

Running the code:
Code (Text):
v=[1;2;3;4;5;6];
P=[2494 4157;1247 2078;831 1386;623 1039;499 831;416 693];
Q = interp1(v,P,5.2,'linear')
returns:
Code (Text):
>> Q

Q =

482.4000  803.4000

When you are running:
Code (Text):
>> v=[1;2;3;4;5;6];
P=[2494 4157;1247 2078;831 1386;623 1039;499 831;416 693];
interp1(v,P,5.2,'linear')

ans =

482.4000  803.4000
The output (a vector) is stored in the variable "ans" and it is displayed since you are not using ";" to close the line.

3. Jul 19, 2011

### GreenPrint

That makes sense. I didn't realize functions output results into a single vector. I guess I just sort of assumed the opposite. It's something my book never informed me of. Thanks for letting me know.

4. Jul 19, 2011