MATLAB Linear Interpolation in MATLAB: Troubleshooting and Tips

AI Thread Summary
The discussion revolves around a user seeking help with MATLAB code for data interpolation. They initially express confusion about using the 'pchip' parameter for cubic interpolation and later confirm that linear interpolation is desired. The user also requests examples of displaying data in a table format and mentions difficulties with their code, specifically that it only prints the last values instead of a complete table. A suggestion is made to explore the array2table() function to address the table formatting issue. Overall, the conversation highlights challenges in understanding MATLAB functions and formatting output effectively.
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: 123
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
 

Similar threads

Back
Top