필터 지우기
필터 지우기

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 CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by