Matlab table
It might be slightly more readable in a semantic way, but if speed is a concern you'll have to try both version and choose which one gives you the best results. Add a private property to the app class for storing the table data (I named it T.
#Matlab table update#
You can also add the update button in design view. You can start by adding a table to the application main figure in App Designer design view. Now I have seen what goes on into varfun, I am not so sure that this solution will be faster. My example is based on the following example, which displays MATLAB table in a uitable (user interface table component).
go figure.)ĭiscussion: Initially I tried to make the varfun solution work (hence the T2 name of the result), and wanted to recommend this one, because I didn't like the table/cell/table conversion of the other solution. Notice that again we had to reassign the column headers on the newly created table ( the irony is varfun choked trying to apply the function on the column headers, but does not re-use or return them in the output. This will produce the same table than in the example 1 above. T2.Properties.VariableNames = T.Properties.VariableNames For example: cellnum2str = with that, you can now use it to convert your table: %% Use "varfun" The trick to overcome that, is to send a customised version of num2str which will accept cell arrays. As we saw above, num2str errors when met with a cell array.
#Matlab table code#
If you look at the varfun code at the line indicated by the error, you'll notice that internally, data in your table are converted to cell arrays and the function is applied to that. You'd think that a simple T2 = varfun(, T ) Varfun is for Tables the equivalent of cellfun for cell arrays. These method is suitable for relatively small tables, as the round trip table/cellarray/table plus the call to cellfun will probably be quite slow for larger tables. Notice that we had to recreate the column names (copied from the initial table), as these are not transferred into the cell array during conversion. Produces a new table containing only strings. T3.Properties.VariableNames = T.Properties.VariableNames T3 = cell2table( cellfun(, table2cell(T), 'uni',0) ) I recreated a table with the same data than in your example.
There are 2 possible way to work around that to convert all your values to character arrays: num2str() is also valid), but it will bomb out if you try to throw a cell array at it (even if all your cells are numeric).
However, it can deal with purely numeric arrays (e.g. Yes, num2str accept a single variable of any type and will return a string, so all these operations are valid: > num2str('123')