# Thread Subject: How to fit a cubic spline code to x,y and z data

 Subject: How to fit a cubic spline code to x,y and z data From: Jayna Patel Date: 26 Apr, 2012 12:37:26 Message: 1 of 2 I have written a code whch allows me to fit missing y values when given x. Is there a way to implement this for data which has the headings of longitudinal, latitude and to use this to find CH4 Data? The code i used for cubic splines for x and y, is the following: x=[0.1838 0.3591 0.4189 0.6284 0.7133 0.8922 0.9213 0.9751]; % x data y=[0.2472 0.6826 0.7814 0.7936 0.4667 0.7926 0.5858 0.6983]; % y data xin=[0.2872 0.7722 0.9222 0.5289]; % where do you want to interpolate at   disp('INPUTS') disp('x data') x disp('y data') y disp('The x data where i want to interpolate at') xin disp(' ')   yin=spline(x,y,xin); % plotting the spline interpolants n=length(x); % find the number of data points xplot=x(1):(x(n)-x(1))/10000:x(n); yplot=spline(x,y,xplot);   disp(' ') disp('OUTPUTS') disp('x values at which function is to be interpolated') xin disp('y values at the xin values') yin xlabel('x'); ylabel('y'); title('y vs x '); plot(x,y,'o','MarkerSize',6,'MarkerEdgeColor','blue','MarkerFaceColor','blue') hold on plot(xin,yin,'o','MarkerSize',8,'MarkerEdgeColor','red','MarkerFaceColor','red') hold on plot(xplot,yplot,'LineWidth',1.5) legend('Points given','Points found','Spline Curve','Location','South') hold off disp(' ') Thank you.
 Subject: How to fit a cubic spline code to x,y and z data From: John D'Errico Date: 26 Apr, 2012 13:18:30 Message: 2 of 2 "Jayna Patel" wrote in message ... > I have written a code whch allows me to fit missing y values when given x. Is there a way to implement this for data which has the headings of longitudinal, latitude and to use this to find CH4 Data? The code i used for cubic splines for x and y, is the following: For z(x,y), use griddata. John

### Everyone's Tags:

Separated by commas
Ex.: root locus, bode

### What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.