I have two vectors, x and y that are defined(at random) as follows:
x1=[1000 3000 5000 6000 4000 2000 500 0 -1000 -3000 -5000 -6000 -4000 -2000 -500 1 999 2999 4999];
y1=[5000 4999 4990 3500 2500 2499 2498 2497 2496 2495 2494 1000 -1000 -999 -998 -997 -996 -995 -994];
Following is the plot I obtained by simply typing in plot(x1,y1):
Is there a way to produce a smooth curve from the above data using the interp1 command? I have been told that I should use cubic splines to achieve the desired plot, however, since I am new to Matlab I am unaware of how to implement such a solution. Thanks in advance!
Edit: I have tried to implement it as follows, but I am getting a hideous looking plot!
x1_temp=-6000:100:6000;
pc=pchip(x1,y1,x1_temp);
plot(x1,y1,'o',x1_temp,pc,'-');
How should I modify this code to produce the right plot?