0
$\begingroup$

I am coding in Matlab:

m = [40 50 60]; X=[];        % [] makes an empty matrix
for j=1:3
    for i=1:3
        x=zeros(m(i),1);     % a vector of m(i) zeros
        X=[X;x];             % store x under the old previous ones
    end
end

and would like to run the code in parallel. Is there a way to calculate from which index to which index in X I will be in a given loop storing in please?

$\endgroup$
  • $\begingroup$ Your question is a bit hard to understand. Perhaps the answer that you're looking for is that $x$ is inserted as row number $3(j-1)+i$ at the $(i,j)$th iteration. $\endgroup$ – Yuval Filmus Oct 11 '19 at 14:19
  • $\begingroup$ thank you very much. that's it :-) $\endgroup$ – Rafael Oct 17 '19 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.