|
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.
|