Borrar filtros
Borrar filtros

Arrange column vetors into table

4 visualizaciones (últimos 30 días)
Panos Kerezoudis
Panos Kerezoudis el 19 de Abr. de 2023
Comentada: Star Strider el 19 de Abr. de 2023
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!

Respuesta aceptada

Star Strider
Star Strider el 19 de Abr. de 2023
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 comentarios
Panos Kerezoudis
Panos Kerezoudis el 19 de Abr. de 2023
it worked, thank you!
Star Strider
Star Strider el 19 de Abr. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by