Solved

Remove the air bubbles

Given a matrix a, return a matrix b in which all the zeros have "bubbled" to the top. That is, any zeros in a given column shoul...

8 years ago

Solved

Pizza!

Given a circular pizza with radius _z_ and thickness _a_, return the pizza's volume. [ _z_ is first input argument.] Non-scor...

8 years ago

Solved

Are all the three given point in the same line?

In this problem the input is the coordinate of the three points in a XY plane? P1(X1,Y1) P2(X2,Y2) P3(X3,Y3) how can...

8 years ago

Solved

Return the 3n+1 sequence for n

A Collatz sequence is the sequence where, for a given number n, the next number in the sequence is either n/2 if the number is e...

8 years ago

Solved

Change a specific color in an image

The ability to change colors can be a useful tool in image processing. Given an m x n x 3 array (much like CData in images), fin...

8 years ago

Solved

Back and Forth Rows

Given a number n, create an n-by-n matrix in which the integers from 1 to n^2 wind back and forth along the rows as shown in the...

8 years ago

Solved

Matrix with different incremental runs

Given a vector of positive integers a = [ 3 2 4 ]; create the matrix where the *i* th column contains the vector *1:a(i)...

8 years ago

Solved

Set the array elements whose value is 13 to 0

Input A either an array or a vector (which can be empty) Output B will be the same size as A . All elements of A equal to 13...

8 years ago

Solved

Getting the indices from a matrice

Getting the indices from a matrice. Inspired by Problem 645. Getting the indices from a vector by the great Doug Hull. Given a...

8 years ago

Solved

Fill a zeros matrix

The aim is to fill an array of all zeros given a numerical value and the index of row and columns for this value. 3 Inputs: ...

8 years ago

Solved

Column Removal

Remove the nth column from input matrix A and return the resulting matrix in output B. So if A = [1 2 3; 4 5 6]; and ...

8 years ago

Solved

Back to basics 23 - Triangular matrix

Covering some basic topics I haven't seen elsewhere on Cody. Given an input matrix, return a matrix with all elements above a...

8 years ago

Answered

total number of elements which are not zero

Hi, what about: B = sum(Percey~=0,2); Regards, W.

total number of elements which are not zero

Hi, what about: B = sum(Percey~=0,2); Regards, W.

8 years ago | 0

| accepted

Problem

Index of neighbor pixel with steepest gradient

Unlike in various applications, where the gradient of a two dimensional matrix is calculated in x and y direction, the gradient ...

8 years ago | 1 | 16 solvers

Answered

How can I perform a comparison function (of surrounding pixels) on a DEM using a starting pixel?

Hi, you might be interested in using the function ixneighbors available on the FEX which might make life a little easier for ...

How can I perform a comparison function (of surrounding pixels) on a DEM using a starting pixel?

Hi, you might be interested in using the function ixneighbors available on the FEX which might make life a little easier for ...

8 years ago | 0

Solved

Bullseye Matrix

Given n (always odd), return output a that has concentric rings of the numbers 1 through (n+1)/2 around the center point. Exampl...

8 years ago

Solved

Select every other element of a vector

Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, s...

8 years ago

Solved

Compute the dilation of a binary image

A basic operation in image analysis is the dilation. Given an image where each pixel is either on or off (black/white, true/fals...

8 years ago

Solved

Trimming Spaces

Given a string, remove all leading and trailing spaces (where space is defined as ASCII 32). Input a = ' singular value deco...

8 years ago

Solved

Vectorize the digits of an Integer

Create a vector of length N for an integer of N digits. x=123045; x_vec=[1 2 3 0 4 5]; I happened upon a trick to do ...

8 years ago

Solved

De-dupe

Remove all the redundant elements in a vector, but keep the first occurrence of each value in its original location. So if a =...

8 years ago

Solved

Most nonzero elements in row

Given the matrix a, return the index r of the row with the most nonzero elements. Assume there will always be exactly one row th...

8 years ago

Solved

Replace NaNs with the number that appears to its left in the row.

Replace NaNs with the number that appears to its left in the row. If there are more than one consecutive NaNs, they should all ...

8 years ago

Answered

Connected graph given adjacency matrix

You can use the function dmperm to see if a graph consists of one or several connected components. E.g. see the example here <h...

Connected graph given adjacency matrix

You can use the function dmperm to see if a graph consists of one or several connected components. E.g. see the example here <h...

8 years ago | 0

| accepted

Solved

Back to basics 11 - Max Integer

Covering some basic topics I haven't seen elsewhere on Cody. Return the largest positive integer MATLAB can handle.

8 years ago

Solved

Back to basics 22 - Rotate a matrix

Covering some basic topics I haven't seen elsewhere on Cody. Rotate the input matrix 90 degrees counterclockwise (e.g. [1 2; ...

8 years ago

Solved

Flip the main diagonal of a matrix

Given a n x n matrix, M, flip its main diagonal. Example: >> M=magic(5); >> flipDiagonal(M) 9 24 1 ...

8 years ago

Solved

Create a square matrix of multiples

Given an input, N, output a matrix N x N with each row containing multiples of the first element of each row. This also applies...

8 years ago