MATLAB: I created a zeros (n+1 by n+1) matrix. And I want the value 2*i on the row (2 : n)&(column 1:n-1) , where i is from 1 to n-1, how should I get that? Can anyone help me out matrix manipulation I tried this : n=4;A=zeros(n+1);for i=2:n-1 A([2:n,2:n-1])=[2*i]endBut it didnt work Best Answer n = 4;A = zeros(n);A(2:n+1:end) = 2*(1:n-1);A(n+1,n+1) = 0; Related SolutionsMATLAB: I want to make every row have same number TryA = repmat((1:N)', [1, N]) MATLAB: Sequence a_n =1/n Use element-wise division: n = 1:100;format shortSeq = 1./nproducing: Seq = 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 ...alternatively: format ratSeq = 1./nproducing: Seq = 1 1/2 1/3 1/4 1/5 1/6 ...EDIT — (17 Jan 2020 at 17:11) Forgot to include the plot call. Here it is: figureplot(Seq)gridThis is the same as: figureplot((1:numel(Seq)), Seq)grid Related QuestionUnderstanding repmat(6,,(1:n*N),1)
Best Answer