Mean values of matrix elements corresponding to increment of fixed column values

2 ビュー (過去 30 日間)
Konstantin Shchukin
Konstantin Shchukin 2024 年 10 月 10 日
編集済み: Voss 2024 年 10 月 10 日
Dear colleagues,
let's assume I have next matrix:
A = [0 1; 3 2; 1 3; 7 4; 2 5; 11 6]
And I have incremental row:
dx = [0.5:2:6.5]
With this increment dx I would like to go throw the 2nd column of matrix A.
How can I make a transformation of the 1st column of matrix A, that each element will be an average value of A(:,1) corresponding for each next step of dx?
The right output will be like this:
dy = [1.5;4;6.5]
Thank you in advance!

採用された回答

Voss
Voss 2024 年 10 月 10 日
編集済み: Voss 2024 年 10 月 10 日
A = [0 1; 3 2; 1 3; 7 4; 2 5; 11 6];
dx = [0.5:2:6.5];
dy = groupsummary(A(:,1),discretize(A(:,2),dx),'mean')
dy = 3×1
1.5000 4.0000 6.5000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by