Hello,
I am trying to accomplish the following: I have a text file that I have read into matlab using the textscan function. The result is an array C{1}....C{31} with 31 columns of information/data. Ideally I would have liked this to be an m X 31 matrix but the data types are different and so I dont know if its possible to create that (is it!!??). One column has values ranging from 0-n and these values repeat (i.e. 0,1,2,3,0,1,2,3,4,5,0...etc). These are slices in mri data sets so they are grouped from slice 0 to slice n. The next 0 represents the start of a next dataset.
I want to loop over this colums. Each time an '0' is encountered I want to create a new array element (or matrix element) and with this element I want to store data values associated with that '0'. Also, I want to store associated data for each following number until the next '0' is reached. And then I want to repeat this process ('0') is like an index then.
In the end I want an array with # elements = however many '0' there were. Under each element I want to be able to access the data for all of the following slices. I cant find a way to increment the array/vector associated with the first slice - I would like to do this in the loop that I use to scan the slice indices so that I can store all associated data a the same time. In the end I would like sorted data for each set.
I hope i've described the problem well and thanks for your help! also if relevent "better ideas" on storting/sorting the data are out there I wont be offended if you suggest them.
2 Comments
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/1117-incrementing-variables-and-storing-data-within-increasing-array-matrix#comment_1912
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/1117-incrementing-variables-and-storing-data-within-increasing-array-matrix#comment_1912
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/1117-incrementing-variables-and-storing-data-within-increasing-array-matrix#comment_1947
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/1117-incrementing-variables-and-storing-data-within-increasing-array-matrix#comment_1947
Sign in to comment.