Clear Filters
Clear Filters

how to increase the weight of a certain point when using smoothing splines?

1 view (last 30 days)
how to increase the weight of a certain point when using smoothing splines?
the certain point is the ionosonde and I want to pass the line fittingcurve through this point
load('data.mat');
rows=size(RO_ISR,1);
for i=1:rows
RO=RO_ISR{i,1};
IONOSODE=RO_ISR{i,2};
x1 = RO.EDP8 * 10^6;
y1 = RO.EDP3;
columns=size(RO_ISR,2);
for j=3:columns
ISR=RO_ISR{i,j};
x2 = ISR.NE8;
y2 = ISR.GDALT;
TT1 = table2timetable(ISR);
TT3 = synchronize(IONOSODE, TT1);
F = fillmissing(TT3,'previous');
ISR_date =ISR.Date;
F_date = F.Date;
[logical_Index ,index] = ismember(ISR_date(1),F_date);
x3=IONOSODE{index,10};
y3=IONOSODE{index,7};
y4 = [y2;y3];% add row y3 to column y2
final_altitude=sort(y4); % sort data in asending form
[logical_Index ,index]= ismember(y3,final_altitude);% find index of y3 in final_altitude
final_ElectronDensity= [x2(1:index-1)', x3, x2(index:end)'];
final_ElectronDensity=final_ElectronDensity';
fittingcurve = csaps(final_altitude,final_ElectronDensity,0.0003,final_altitude);
figure;
hold on;
plot(x1, y1);
plot(x2, y2);
plot (x3, y3,'-s','MarkerSize',9, ...
'MarkerEdgeColor','blue', ...
'MarkerFaceColor',[1 .4 .4])
plot(fittingcurve,final_altitude,'g');
xlabel('Electron Density');
ylabel('Altitude');
title('Plotting');
legend('RO', 'ISR','ionosonde', 'fitting curve');
hold off;
end
end
  2 Comments
John D'Errico
John D'Errico on 4 Jul 2023
A bit impatient, are you? You might recognize that you asked a question at a time that would have been in the middle of the night for all of the US, where many of the people live who might be able or willing to answer your question.

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 4 Jul 2023
Just read the help for csaps. Here is a link for the doc: csaps
In there, I find this line:
pp = csaps(x,y,p,[],w) also specifies the weights w in the error measure
HOWEVER, just increasing the weight on a point will not force the curve to pass exactly through that point. It will reduce the degree the curve misses that point. But not exactly force the fit. And if you too massively increase one weight, this may also introduce numerical problems in the fit.
You might decide to use other tools, like my SLM toolbox, which can do smoothing, as well as force a fit through any given point or set of points. You can find SLM for free download from the File Exchange.
  1 Comment
t
t on 4 Jul 2023
I did not understand the doc in the link, but I tried this
pp= csaps(final_altitude,final_ElectronDensity,0.2,[ones(1,10),repmat(5,1,10), 0]);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!