Linear Interpolation in MATLAB: Troubleshooting and Tips

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
6 replies · 3K views
ineedhelpnow
Messages
649
Reaction score
0
View attachment 5032hi! here's my question. here's my code. i have no idea what to do now :(

Code:
x = 0:9;
y = [0.053 1.477 1.970 3.279 4.153 4.934 5.178 5.828 6.082 6.484]; % data
X = linspace(0,8.5,1);
Y = interp1(x,y,X,'pchip')
 

Attachments

  • Untitled.png
    Untitled.png
    12.9 KB · Views: 159
Physics news on Phys.org
I know nothing about MATLAB, but isn't the parameter [m]'pchip'[/m] used for cubic interpolation?

It seems to be after looking at the MATLAB documentation, we want to begin with code like:

Code:
v = [0.053 1.477 1.970 3.279 4.153 4.934 5.178 5.828 6.082 6.484];
xq = 0.5:8.5;
vq = interp1(v,xq);
 
thank you :) yeah it should have been linear
 
ineedhelpnow said:
thank you :) yeah it should have been linear

Do you have any examples where data is displayed in a table format?
 
no :( that's mainly what I am stuck on
 
ineedhelpnow said:
no :( that's mainly what I am stuck on

It looks like the [m]array2table()[/m] function could be a place to look. :D
 
Thank You! There's another problem with my code. Like when I print it I'll only get the last values. Not a table of values