Associate the value to the correct string

1 view (last 30 days)
gcicceri
gcicceri on 9 Jul 2020
Edited: gcicceri on 9 Jul 2020
Hi guys,
I have a (mxn) table:
table_1:
Date var_1 var_2 var_3 var_4
01-01-90 0.03 0 0.29 0
01-01-91 0.03 0.30 0.53 0.30
01-01-92 0.02 0.20 0.56 0.39
01-01-93 0.01 0.19 0.57 0.37
01-01-94 0.06 0.20 0.33 0.43
.........................................................................
.........................................................................
and a (mxn)string: (consider now the columns)
1 2 3
var_3 var_1 var_2
var_1 var_2 var_3
var_4 var_4 var_4
var_2 var_3 var_1
My question is:
how do I associate the value of next year (row) of the table_1 directly from the name of the string?
This should be the result:
table_3:
1 2 3
0.53 0.02 0.19
0.03 0.20 0.57
0.30 0.39 0.37
0.30 0.56 0.01
  1 Comment
Image Analyst
Image Analyst on 9 Jul 2020
Edited: Image Analyst on 9 Jul 2020
Are you wanting to know how to use sort() on each table row independently? Like sort the table with the 'var_n' strings in it, and then reshuffle the table with the numbers to use the same sort order as you got from the table with the strings?
Make it easy for us to help you by supplying us with code to generate the string table and the numbers table.

Sign in to comment.

Answers (1)

gcicceri
gcicceri on 9 Jul 2020
Edited: gcicceri on 9 Jul 2020
I don't need to sort() the table, I just need to transfer the associated values of the column names to another table.
The table is the one you see. Also the result of how must be.

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!