Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's one way to do it for a given element of the cell matrix:</p> <pre><code>full=zeros(7200,3)+NaN; for i = 1:20 % for each day starti = (i-1)*360; % find corresponding 360 indices into full array full( starti + (1:360), 1 ) = i; % assign the day idx = find(a(:,1)==i); % find any matching data in a for that day full( starti + (1:length(idx)), 2:3 ) = a(idx,2:3); % copy matching data over end </code></pre> <p>You could probably use <code>arrayfun</code> to make this slicker, and maybe (??) faster.</p> <p>You could make this into a function and use <code>cellfun</code> to apply it to your cell.</p> <p>PS - if you ask your question at the <a href="http://www.mathworks.com/matlabcentral/newsreader/" rel="nofollow">Matlab help forums</a> you'll <strong>most definitely</strong> get a slicker &amp; more efficient answer than this. Probably involving <code>bsxfun</code> or <code>arrayfun</code> or <code>accumarray</code> or something like that.</p> <p><strong>Update</strong> - to do this for each element in the cell array the only change is that instead of searching for <code>i</code> as the day number you calculate it based on how far allong the cell array you are. You'd do something like (untested):</p> <pre><code>for k = 1:length(cellarray) for i = 1:length(cellarray{k}) starti = (i-1)*360; % ... as before day = (k-1)*20 + i; % first cell is days 1-20, second is 21-40,... full( starti + (1:360),1 ) = day; % &lt;-- replace i with day idx = find(a(:,1)==day); % &lt;-- replace i with day full( starti + (1:length(idx)), 2:3 ) = a(idx,2:3); % same as before end end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload