incrementing variables and storing data within increasing array/matrix

3 visualizaciones (últimos 30 días)
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 comentarios
Jan
Jan el 9 de Feb. de 2011
It is nearly impossible to give a valuable answer, if you do not post any code. Even a very good answer cannot match your problem exactly, if you describe in with words only.
Oleg Komarov
Oleg Komarov el 10 de Feb. de 2011
Can you post the content of C{1}(1:10), C{2}(1:10),..., C{5}(1:10) to get an idea of what we should do when 0 is encoutered. Also which is the column with the mri slices?

Iniciar sesión para comentar.

Respuestas (1)

n
n el 9 de Feb. de 2011
Hi, I am not sure if this would help or not but you can use the wizard: Open Import Wizard to import data: *uiimport * define how you want to import your data from the file and you can tick to generate its own m-file to run over similar other data files that you have from then on. Still I think you are able to work on cells almost the same way as you can work with matrices. You can also produce matrices from cells if the vectors have same dimensions. May be if you simplify your question people can answer it better. Good luck

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by