MATLAB: How to make a column vector of 2 distinct numbers cell arraymatrix arrayvector How can I make a 400×1 column vector in the following format.. first 100 rows = all 1's 101st to 400th row = all 2's I am a matlab newbie so any help to get me started will be greatly appreciated. Thanks Best Answer Many possible solutionsV = [ones(100,1);2*ones(300,1)];or V = [repmat(1,100,1);repmat(2,300,1)];orV = ones(400,1); V(101:end)=2;orV(1:100,1)=1;V(101:400,1)=2; Related SolutionsMATLAB: Highlight cells in heatmap You can do so by creating a custom colormap. The code below shows a simple implementation.xvalues = 1:5;yvalues = 1:5;cdata = randi(20,[5,5]); % range of values in cells < 20cmap = [repmat([1 0 0],5,1) repmat([1 1 1],5,1) % highlight all cells with values from 5-10 with white repmat([0 0 0],10,1)]; % highlight all cells > 10 with blackheatmap(1:5,1:5,randi(20,[5 5]),'Colormap',cmap); MATLAB: Need to detect repeating values in 2 columns a certain number of times all(data(1:end-2, :) == data(2:end-1,:) & data(2:end-1,:) == data(3:end,:),2) Related QuestionHow to multiply simplest way this two vectorsHold on not working with ezplot3Create a Cell Array of Vectors populated with onesBuild 2-D array with same 1-D arrayHow to set every other number in an array to a specific number with one line
Best Answer