How to apply calculation over multiple columns in a matrix

3 ビュー (過去 30 日間)
Eleonora Montagnani
Eleonora Montagnani 2023 年 9 月 15 日
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!!!!!!

採用された回答

Matt J
Matt J 2023 年 9 月 15 日
編集済み: Matt J 2023 年 9 月 15 日
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 件のコメント
Adam Danz
Adam Danz 2023 年 9 月 15 日
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 2023 年 9 月 15 日
Thanks Matt, it did work, in my code I just missed to add ' to define the transpose!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by