Error in Spline (interpolation)
4 ビュー (過去 30 日間)
古いコメントを表示
I am using interp1 to do a spline interpolation and I get the below output:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 5.270915e-022. > In spline at 91 In interp1 at 279 ...and blah blah blah (more layers)
This is how I called it:
for i = 1:length(fields)
eval(['interpolated.', fields{i},' = interp1(choppedT1,chopped.',fields{i},',choppedMaster, ''spline'');']);
end
"chopped" is a structure of vectrs that have been "chopped" to be the same length. choppedT1 is the timestamp vector for these vectors. choppedMaster is the timestamp vector I am interpolating to. Fields is the array of fieldnames (same for chopped and interpolated). I'm using eval like this because it allows for any fieldname to be used. any ideas?
0 件のコメント
回答 (1 件)
Bruno Luong
2011 年 2 月 10 日
The warning message issued possible due to there are abscissa (chopped filed) too close to each other. You could group them then average to a single data point before interpolation.
Note that structure fields can be accessed using dynamic fieldname, e.g.,
interpolated.(fields{i}) = ...
That syntax allows you to remove all the eye-hurting eval().
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!