Arrange column vetors into table

4 ビュー (過去 30 日間)
Panos Kerezoudis
Panos Kerezoudis 2023 年 4 月 19 日
コメント済み: Star Strider 2023 年 4 月 19 日
Hi!
I used the findpeaks function in matlab to find local maxima ('peaks') in a vector and their indices ('locs').
I would like to arrange the two outputs in a table. I used the table function to merge them, but this is what I get, instead of numbers.
I tried converting the variables to num but i didnt help.
Any thoughts?
Thx in advance!

採用された回答

Star Strider
Star Strider 2023 年 4 月 19 日
You simply need to transpose the row vectors to column vectors.
That is best done before creating the table, for example —
peaks = rand(1,11)
peaks = 1×11
0.2360 0.9313 0.5730 0.5696 0.8913 0.5849 0.9910 0.7940 0.0096 0.5015 0.8101
locs = sort(randi(25,1,11))
locs = 1×11
7 13 14 15 16 17 18 18 19 21 22
peaks = peaks(:)
peaks = 11×1
0.2360 0.9313 0.5730 0.5696 0.8913 0.5849 0.9910 0.7940 0.0096 0.5015
locs = locs(:)
locs = 11×1
7 13 14 15 16 17 18 18 19 21
A = table(peaks,locs)
A = 11×2 table
peaks locs _________ ____ 0.23596 7 0.93131 13 0.57302 14 0.56964 15 0.89127 16 0.58491 17 0.99104 18 0.79404 18 0.0095785 19 0.50147 21 0.81009 22
.
  2 件のコメント
Panos Kerezoudis
Panos Kerezoudis 2023 年 4 月 19 日
it worked, thank you!
Star Strider
Star Strider 2023 年 4 月 19 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by