How to apply calculation over multiple columns in a matrix

5 visualizaciones (últimos 30 días)
Hello,
I have a matrix (1503x7) where each column is a time series data. I need to apply the following calculation to each column in my matrix, so that each time data serie (each column) will be normalized to 100 points:
x = linspace(0,100,length(presentMatrix));
y = 0:100;
newMatrix= spline(x,presentMatrix y);
Any suggestion how to do it? Thank you!!!!!!

Respuesta aceptada

Matt J
Matt J el 15 de Sept. de 2023
Editada: Matt J el 15 de Sept. de 2023
The code you've posted already does it, after transposition.
x = linspace(0,100,length(presentMatrix));
y = 0:100;
newMatrix= spline(x,presentMatrix', y)';
  2 comentarios
Adam Danz
Adam Danz el 15 de Sept. de 2023
I'd use height(presentMatrix) rather than length(). If this is every applied to a matrix that is wider than it is tall, this will fail.
Eleonora Montagnani
Eleonora Montagnani el 15 de Sept. de 2023
Thanks Matt, it did work, in my code I just missed to add ' to define the transpose!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by