Prev: resizing plots
Next: open named notepad file
From: Anabel on 14 Jul 2010 10:50 Hi! I've searched for help in newgroups and tutorials becuase my doubt is pretty easy but I just cannot find a solution. I hope you can help me. I explain you a simplified version of the problem. Let's say I have: - c is 90 x 3 matrix (preallocated) - data is an array of struct, length 9 - data(i).firstfield length is 10 and it has integers I want to fill in the first column of c with the first fields of each cell of the array. I can do it for the first cell with this code, but I don't know how to update the index of c to keep filling in. I'd need something like concatenate I guess. for i=1:length(data) c (1:length(data(i).firsthfield), 1) = data(i).firstfield; end Thanks
From: Anabel on 14 Jul 2010 11:13 I want to add also that if it is easier and better I'm open to suggestions and changes. For example c can be a cell array instead of a matrix if it's easier to handle. Or I could have 3 column vectors instead of the matrix (I can always rearrange them later). Basically c can be whatever but data is done. I have to do the same for the 3rd column of c with data(i).secondfield)
From: Andy on 14 Jul 2010 11:30 % Caveat: I don't have access to MATLAB right now, so this is untested % assuming data(i).firstfield is a 10x1 array: c(:,1) = vertcat(data(:).firstfield); % if data(i).firstfield is a 1x10 array, you should transpose
From: Anabel on 14 Jul 2010 11:44 IT WORKS! I knew it was simple but I just couldn't find it. :) Thank you very much! Anabel.
|
Pages: 1 Prev: resizing plots Next: open named notepad file |