Operation on multiple arrays

5 views (last 30 days)
Paavo Auvinen
Paavo Auvinen on 8 Mar 2019
Commented: Paavo Auvinen on 11 Mar 2019
I am struggling with a following problem. I have large amounts of experimental data. I import the time stamps as one column arrays in datetime format.
Let's call these arrays A,B,C... Now, for plotting I want to change the format to 'mm:ss', so I write A.Format='mm:ss'
Is there a convinient way to perform this Format operation (and similar operations) on several arrays at once or is For-loop and proper naming the only option?
I tried something like (A,B,C,D...).Format='mm:ss' but obviously without results.
Thank you for your help!
  4 Comments
Stephen23
Stephen23 on 11 Mar 2019
Edited: Stephen23 on 11 Mar 2019
"I guess I could combine the arrays, however, my aim is to be able to process the data fast and avoid extra steps."
Importing your file data into one array is the fast way to solve this quickly and to avoid extra steps. Importing file data into one array is exactly what the MATLAB documentation shows:
"For technical reasons I get the data in separate files which results in several imported arrays."
The separate arrays should be combined into one numeric array, or stored in one container array (e.g. a cell array, as the MATLAB documentation shows), when you import the data.
"Trying to figure out the efficient way to this in MatLab as I'm eager to start using it over spreadsheet softwares."
The efficient way to do this is to import your data into one array, which you can trivially access using neat, simple, and very efficient indexing. In contrast, the approach you are trying forces you to write slow, complex, buggy, hard-to-debug code. Read this to know some of the reasons why:
Paavo Auvinen
Paavo Auvinen on 11 Mar 2019
Thank you for your insight, it was most helpful.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!