Different length data - not able to use structures, matrix, or eval. What can I use?
Show older comments
I'm performing some data analysis over and over on different data sets.
The initial data set is a matrix, where each column is a variable over time. I'm extracting two of these columns (time and mph) and performing analysis on them.
I am doing this for many data sets. However, each data set has a different number of rows (it depends on how long the simulation was running)
So I cannot create a matrix called 'time' with each column being a different data set as the data sets are different lengths. I have the same problem with structures.
I have not been able to get 'eval' (in order to create named variables such as time_1, time_2) to work with arrays.
Is there any thing else I can use?
Accepted Answer
More Answers (1)
Jason Ross
on 1 Feb 2013
Edited: Jason Ross
on 1 Feb 2013
Why can't you use operators like colon or end to allow data of different sizes to be imported? You can effectively say "give me all the data in this row" or "give me all the data starting from X and then stopping 5 away from the end"
Example:
>> m = magic(5)
m =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
>> out1 = m(4,:)
out1 =
10 12 19 21 3
>> out2 = m(:,4)
out2 =
8
14
20
21
2
>> out3 = m(2,1:end-2)
out3 =
23 5 7
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!