MATLAB: Going from 1 x n to n x n matrix repmat How doe I convert a matrix with 100 elements in a 1×100 matrix to a 100×100 matrix. Each row in the 1xn matrix will have the same values in rows 2, 3, 4, 5 etc to 100 Best Answer repmat(A,100,1)where A is your vector. Related SolutionsMATLAB: N(x) CODE1)a=[0 1]; % you tell MATLAB a is a vectorfor r=3:100 % the for loop you understand, right? a(r)=(r-1)+(r-2); % you're attributing to the rth term of your vector a values of (r - 1) + (r - 2) % the 1st iteration will be a(3) = (3 - 1) + (3 - 2); a(4) = (4 - 1) + (4 - 2); so on...enddisp(a)CODE2) a=[0 1]; %from this line, a(1) = 0 and a(2) = 1.for r=3:100 a(r)=a(r-1)+a(r-2); % the difference between this and code 1) is that you're performing % the summation calling the indexes in the vector a, rather than r values. % so a(3) = a(2) + a(1) = 0 + 1 = 1 % In code 1, a(3) = 2 + 1 = 3enddisp(a)Code 3) is the same as 2) Walter mentioned.Hope that helps...Cheers MATLAB: Initialize a multidimensional matrix N=6;m=4;A=zeros(repmat(m,1,n)); Related QuestionExponential element wise multiplication in matrixHow to multiply 7 x 1 matrix with 400 x 1 matrixGenerate y(n)=y(n-1)+x(n)Transforming a multidimensional array to a two dimensional arrayConverting from 1 x n x 3 to n x 3
Best Answer