How to convert one row of a table to a vector?

32 views (last 30 days)
Now I have a table and I want to convert one row to a vector. I firstly used table2array, then cell2mat. However the result is a string rather than a vector. As shown in the picture. How can I complete the transformation? Thanks!

Accepted Answer

Yujian Wu
Yujian Wu on 13 Jan 2018
I'm sorry, this is the right method. As all the data of my first row are '0', so the converted array look like a string of 0. After changing the data type, I can get the vector of num.
  2 Comments
per isakson
per isakson on 13 Jan 2018
Edited: per isakson on 13 Jan 2018
What "this is the right method" ?
tbl = array2table( magic(5) );
row = tbl{ 2, : }
returns
row =
23 5 7 14 16
Yujian Wu
Yujian Wu on 13 Jan 2018
Thank you! The right method means the two steps in my question: table2array then cell2mat.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion 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!