Gistlib Logo

gistlib

create a function file for a which is an array of m x n ones and the top left and bottom left quarters of the matrix are all zeros in matlab

main.m
function onesMatrix = createOnesMatrix(m, n)
    onesMatrix = ones(m, n);  % create matrix of all ones
    onesMatrix(1:m/2, 1:n/2) = 0;  % top left quarter set to zero
    onesMatrix(m/2+1:end, 1:n/2) = 0;  % bottom left quarter set to zero
end
246 chars
6 lines

similar matlab code snippets

how to calculate the mean of a matrix in matlab
function to covert mnist to mat in matlab
write an matlab function that will take a (4 × 4) matrix as an input argument, and will average the values of each row, inputting the found values on the main diagonal of the matrix. in matlab
create a function that gets the average of a 2x3 matrix in matlab
design the function function out = x_m(x,m) with input data matrix x of size 𝑁 × 𝑑 in matlab
design a function that runs a every digit from a matrox in matlab
finding maximum number in a row in matlab
how to calculate the standard deviation of a matrix in matlab
how to calculate the mode of a matrix in matlab
how to calculate the variance of a matrix in matlab

related categories

matlab
matrix
function

gistlibby LogSnag