I have trouble making a certain matrix even though it seems trivial. For my code I need to make a 4-D matrix A with dimensions 2x100xmax(K)xP where P=8 and K=round(linspace(1000,2000,P)) . The matrix needs to be all ones, except for K indexes larger than the K that corresponds with the P. For example, A(:,:,:,1) should be all ones except for K's larger than 1000 which should be zeros, and A(:,:,:,8) should be solely ones.
I tried code like
P = 8;K = round(linspace(1000,2000,P));A = zeros(2,100,max(K),P);for i=1:P A(:,:,:,i) = ones(2,N,K(i));end
But as my command window showed that is clearly not the way to go.
Best Answer