How to get the x, y data after using smoothing spline in Matlab?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have tried the below code to get the x,y data after using smoothing spline. I am still confused with
h = findobj(gca,'Type','line');
x=get(h,'Xdata');
y=get(h,'Ydata');
Is it all the x y data obtained after smoothing ? I feel very less data is showing in x, y.Please let me know where I am going wrong? Here is my code..
%Load the x-axis data
filename1 = 'Time.xlsx';
Time = xlsread(filename1);
%Load the y-axis data
filename2 = 'X.xlsx';
X= xlsread(filename2);
%Performing smoothing spline
% Time and X are input data
[f,gof,out] = fit( Time, X, 'smoothingspline');
% Plot fit with data.
figure( 'Name', 'TimeVsX' );
h=plot(f,'fit');
legend(h,'After Smoothing', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label the axes
xlabel( 'Time', 'Interpreter', 'none' );
ylabel( 'X', 'Interpreter', 'none' );
grid on
h = findobj(gca,'Type','line');
x=get(h,'Xdata');
y=get(h,'Ydata');
0 comentarios
Respuestas (1)
KSSV
el 27 de Oct. de 2021
%Load the x-axis data
filename1 = 'Time.xlsx';
Time = xlsread(filename1);
%Load the y-axis data
filename2 = 'X.xlsx';
X= xlsread(filename2);
%Performing smoothing spline
% Time and X are input data
[f,gof,out] = fit( Time, X, 'smoothingspline');
% get smoothed values
X_smooth = f(Time)
5 comentarios
KSSV
el 27 de Oct. de 2021
n = 500 ;
Time_i = linspace(min(Time),max(Time),n);
X_smooth = f(Time_i)
Ver también
Categorías
Más información sobre Smoothing 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!