Cubic smooth spline plot in 3d for several layers
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gabriel Fouillon
el 19 de Feb. de 2020
Comentada: darova
el 24 de Feb. de 2020
Hello I have vectors
iv3,iv28,iv48,iv68,iv133,iv268,iv398 (each of length 83x1 - positive real numbers)
and one vector named strikes (length 83x1 - positive real numbers)
The iv3 vector refers to implied volatility data from day 3, the iv28 from day 28 and so on (this means we have a time axis of 7 days with day 3,day 28,...,day 398)
I need to do smooth spline interpolation for each pair (strikes,iv3) ,(strikes,iv28), ...,(strikes,iv398) and I use csaps().
csaps() works totally fine in 2d. Problem is I need to put all 2d plots in one 3d plot. But I do not need one surface over the whole observations in 3d, rather for each day and each pair (strikes,iv28), (strikes,iv48), ....(strikes,iv398) one smoothing spline (in total 7 splines per pair and time) -
spline1 one on (strikes,iv3, day3) ,
spline2 one on (strikes,iv28, day28)
,...,
spline7 one on (strikes,iv398, day398)
I came so far to plot the (unsmoothed) 3d observation graph (without the splines).
Now i need to do the smoothing for each observation pair in 3d.
Since csaps() and fnplt() do not work for 3d I need a workaround for 3d.
Also important is that I would like to have a smoothing parameter (lambda) which determines the smoothnes of the spline. As mentioned csaps does this perfectly, but does unfortunately not work for 3d graphics!
--------------------
To the graphic below! Every dot line needs to get its spline that smooths the data. Splines are missing in the graphic!
Plot command was (here for day 3) plot3(repmat(3,length(strikes),1),strikes,iv3,'.')
This was commanded then for each data tripel (days,strikes, iv), hence the other lines.
And here the day3 data with yellow=spline(via csaps(strikes,iv3,0.001)) and blue=real observations
Kind Regards
Gabriel
5 comentarios
Respuesta aceptada
Gabriel Fouillon
el 21 de Feb. de 2020
Editada: Gabriel Fouillon
el 21 de Feb. de 2020
2 comentarios
Más respuestas (2)
darova
el 21 de Feb. de 2020
Maybe you don't need interpolation. I just removed NaN numbers
D = importdata('Data.txt');
A = D.data;
x = A(:,1);
cla
hold on
for i = 2:size(A,2)
ix = ~isnan(A(:,i));
x1 = x(ix);
y1 = A(ix,i);
plot3(x,x*0+i,A(:,i),'.b')
plot3(x1,x1*0+i,y1)
end
hold off
3 comentarios
darova
el 21 de Feb. de 2020
- I will come back to you hopefully with the right plot.
I will be waiting infinitely
Gabriel Fouillon
el 23 de Feb. de 2020
7 comentarios
darova
el 24 de Feb. de 2020
This is how your data looks like (XY plane)
If you want to interpolate along time axis (Y) you need red points. Sometimes you have NaN
So you can't interpolate curve there
Ver también
Categorías
Más información sobre Spline Postprocessing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!