Borrar filtros
Borrar filtros

Smoothed curve new x and y coordinates

6 visualizaciones (últimos 30 días)
Antoine
Antoine el 22 de Feb. de 2023
Comentada: Corey Silva el 14 de Mzo. de 2023
I have X and Y data on excel
I imported the table to matlab and plotted the curve and then smoothed it.
How can i get the new values of X and Y of the smoothed curve ?
Thank You
  2 comentarios
Askic V
Askic V el 22 de Feb. de 2023
Editada: Askic V el 22 de Feb. de 2023
The question should be how to get smoothed Y values, because X values should stay the same.
Probably as an output from your smoothing function or whatever you applied on the Y data.
y_smooth = smooth(Y)
Akira Agata
Akira Agata el 22 de Feb. de 2023
I believe smoothdata function's help page will be some help.

Iniciar sesión para comentar.

Respuestas (1)

Naren
Naren el 1 de Mzo. de 2023
Refer to the below code which possibly resolves your problem.
data = readtable('mydata.xlsx');
x = data.X; % Assuming the column with X data is named "X"
y = data.Y; % Assuming the column with Y data is named "Y"
% Smooth the curve using moving average
windowSize = 5;
smoothY = movmean(y,windowSize);
% You can plot the both and compare for better understanding
figure;
plot(x,y);
hold on;
plot(x,smoothY);
%export the smoothed data into a excel file
smoothData = table(x,smoothY) % table containing smoothed y values.
writetable(smoothData,'smoothed_data.xlsx');
This code assumes that your X and Y data are in separate columns in your Excel file named "mydata.xlsx". The code reads in the data using the readtable() function, and then extracts the X and Y data into separate variables, and then applies a moving average smoothing to the Y data using the movmean() function.
Finally, the smoothed data is saved to a new Excel file using the writetable() function. The new file will contain two columns, one for X and one for the smoothed Y values.
Refer the documentation below for further information.
  1 comentario
Corey Silva
Corey Silva el 14 de Mzo. de 2023
The smoothdata function will help you out here.
You can simply use the table as an input to this function.
>> smoothdata(t,"movmean") % smoothes the data contained in the table t with the "movmean" method

Iniciar sesión para comentar.

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!

Translated by