Quantcast
Channel: MATLAB Central Newsreader - tag:"table"
Viewing all articles
Browse latest Browse all 48

assigning doubles to a table

$
0
0
I'm trying to convert dates in a table, with variable name date_table, to their serial date equivalents and then store these numbers (as doubles) back in the original table. The first part is fine using datenum(), but I'm having issues storing the numbers in the table. I've tried the following things with the corresponding errors. I know it's just a misunderstanding I have about classes, but I can't figure out what it is.

>> date_table(:,1) = datenum(date_table{:,1}, 2000);
Right hand side of an assignment into a table must be another table or a cell array.

>> date_table{:,1} = datenum(date_table{:,1}, 2000);
Conversion to cell from double is not possible.

>> date_table(:,1) = {datenum(date_table{:,1}, 2000)};
No error here, but it stores the ENTIRE vector of numbers in each entry of date_table.

>> date_table{:,1} = {datenum(date_table{:,1}, 2000)};
No error here, but it stores the ENTIRE vector of numbers in each entry of date_table.

date_table{:,1} = num2cell(datenum(date_table{:,1}, 2000));
This is the closest I've come. The issue here is that when I enter class(date_table{:,1}) it says that the column is a cell, and I want it to be a double.

Viewing all articles
Browse latest Browse all 48

Trending Articles