MATLAB: Saving selected array of data from set of output array

arraysave

Hello
My problem looks similar to the following –
for ii = 1:1000
x = cos(ii)*{a 1by1000 array}
end
Now, out of this 1000 results for x, i want to save only few data sets; like at ii=1,100,200,300….,1000. The problem that i am handling in real has millions of loops but i need just a few array. Can anyone please help me to get a solution.
Thanks in advance.

Best Answer

  • a=rand(1,1000);
    cii=cos([1 100:100:1000]),
    x=bsxfun(@times,a,cii') % result = array 11x1000