Cubic smooth spline plot in 3d for several layers
이전 댓글 표시
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
darova
2020년 2월 20일
How is it going?
Gabriel Fouillon
2020년 2월 20일
편집: Gabriel Fouillon
2020년 2월 20일
darova
2020년 2월 20일
Do you have data?
Gabriel Fouillon
2020년 2월 21일
채택된 답변
추가 답변 (2개)
darova
2020년 2월 21일
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
Gabriel Fouillon
2020년 2월 21일
darova
2020년 2월 21일
- I will come back to you hopefully with the right plot.
I will be waiting infinitely
Gabriel Fouillon
2020년 2월 23일
Gabriel Fouillon
2020년 2월 23일
0 개 추천
댓글 수: 7
darova
2020년 2월 23일
griddata?
Gabriel Fouillon
2020년 2월 23일
darova
2020년 2월 23일
- I would like to smooth again over the time axis,with a smooth spline interpolation, so that i have a smooth surface
I mean that you can use griddata to create surface or smooth your data along time axis
Gabriel Fouillon
2020년 2월 23일
darova
2020년 2월 23일
I don't think griddata has that property/feature
But you can try different types of interpolation: 'linear', 'natural', 'cubic' and so on
Gabriel Fouillon
2020년 2월 24일
편집: Gabriel Fouillon
2020년 2월 24일
darova
2020년 2월 24일
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
카테고리
도움말 센터 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


