필터 지우기
필터 지우기

How to get the x, y data after using smoothing spline in Matlab?

조회 수: 9 (최근 30일)
Aarach Sap
Aarach Sap 2021년 10월 27일
댓글: Aarach Sap 2021년 10월 28일
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');

답변 (1개)

KSSV
KSSV 2021년 10월 27일
%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
KSSV
KSSV 2021년 10월 27일
n = 500 ;
Time_i = linspace(min(Time),max(Time),n);
X_smooth = f(Time_i)
Aarach Sap
Aarach Sap 2021년 10월 28일
I am still not getting. I just want the points or data after smoothing. I can fix the range from app also but i am not getting the values from apps, only can generate code. According to above my code, the values can be obtained by
X_smooth = f(Time)
Y_smooth = f(X) ???? plz let me know

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Smoothing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by