MATLAB: Hi every one , Is there any way to fill specific cells of a matrix with random number Not all the matrix randi Best Answer It is easiest to use linear indexing for your problem.The Code —A = zeros(3,5);A([3 4 5 8 10 12 13 15]) = randi(9, 1, 8)A = 0 2 0 1 2 0 5 4 0 0 6 0 0 2 7Since the numbers are random, you will get different results. The numbers will be in the required locations in ‘A’. Related SolutionsMATLAB: Complete a matrix by means of another matrix Use interp1 and linear interpolation, e.g.:>> FR = [0.1,0.3,0.5,0.6,0.7];>> MR = [ 1 3, 5, 6, 7];>> Fx = 0.1:0.1:0.6;>> Mx = interp1(FR,MR,Fx)Mx = 1.0 2.0 3.0 4.0 5.0 6.0 MATLAB: How to replace zeros’s with o.1 in the ouput Try this:duration = randi([0 9], 1, 15) % Create Vectorduration(duration == 0) = 0.1duration = 9 0 4 0 8 7 1 4duration = 9 0.1 4 0.1 8 7 1 4 Related QuestionFill matrix with zerosFill row of matrixHi, i’m trying to make a condition that states ‘only if the difference between two values is greater than 0.1 then plot’. What would be the code for this? Thanks :)Fill in a matrixConcatenation or addition of matrixFill matrix from cell matrix
Best Answer