Reputation: 2617
I'm trying to store a series of formated numbers as a strings in a table and I need to preserve all the white spaces. I don't know if there's a better way to store strings in a table (any recommendation would be appriciated) but this is what I'm using.
% Initialize table
mytable = array2table(cell(5,5));
% Variables
a = 0.04;
I want to store '0.04 ' (with 2 blank spaces at the end) in the first cell of mytable. This is what I tried:
mytable{1,1} = cellstr([num2str(a), ' ']);
However, I know that cellstr()
doesn't preserve white spaces. I don't know what function to use to store the variables. I tried with char()
but I'm getting errors. Thank you!
Upvotes: 0
Views: 237