MATLAB Answers

0

How can I convert several tables into cell arrays

Asked by Antonio Melieni on 30 Mar 2019
Latest activity Edited by Stephen Cobeldick on 31 Mar 2019
Hi :)
I have 6 tables in my workspace and I want to convert them all into cell arrays.
Is this possilble by a loop for example? I dont want to convert every table in an extra step
Thx :)

  10 Comments

dpb
on 30 Mar 2019
Adding to G's comment "do not create numbered variables..."
Nor sequentially-ASCII named ones with meta-date encoded in them as your LHS variables.
As far as your Q? of "right" -- the code may be syntactically correct and do what it says, but it is NOT the right solution to the problem owing to the above data storage issues...
Don't keep us in the dark guessing...show the input file (or a piece of it if it is really large) and describe briefly your objectives...
First of all, thanks for your help :)
Im writing my bachelorthesis about foreign exchange rates
I have to do a timeseries analysis of minutley based data from 01.01.18-01.01.19 of four currency pairs. The datasets came as csv files.
I have to calculate several variables like the price, which for example ist the mean of (bid and ask price)/2, volatility and so on.
Attached you find a screen shot, as i couldnt upload some data....
Sorry for the stupid questions but im using matlab since 5 days and i had no lessons at all and 8 weeks to finish my thesis....
As dpb and Guillaume have already mentioned, don't stick meta-data (e.g. numbers, test-case names, parameter values, etc) into your variable names (unless you want to force yourself into writing slow, complex, buggy code that is hard to debug). Just use indexing. Indexing is simple and very efficient.
"The datasets came as csv files."
Then just follow the MATLAB documentation examples for importing multiple files:
Import the data as a numeric array or a table or whatever works best, and simply store them in one cell array using indexing:
"How can I convert several tables into cell arrays"
It is unlikely that this is necessary or even a good way to achieve your goal. Just access the data directly from the table (in the cell array).

Sign in to comment.

0 Answers