Dear all, Pertaining to the above subject. I want to assign the elements in vector S to the TABLE at each of the locations as defined in the vector NUMS
nums =[5;6;7;12;13;14;16;17;18];v1_threshold = 0.1:0.1:0.2;table = cell2table (repmat({nan},20,(numel(v1_threshold))));S =[1,1,1,1,1,1,1,0,1];
The expected output in the TABLE should be something like
Table = {NaN;NaN;NaN;NaN;1;1;1;NaN;NaN;NaN;NaN;1;1;1;NaN;1;0;1;NaN;NaN} % Element in column 1 of TABLE
Table ={NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN} % Element in column 2 of TABLE
Initially, I thought the code should be something like
VV = num2cell (S);for i =1:length (VV)table (nums(i),1) = VV (i) ;end
However, I am interested to know if there is a way to avoid the FOR loop?
I really appreciate if someone can show what I have been missing?
Best Answer