Solved

Nearest Numbers

Given a row vector of numbers, find the indices of the two nearest numbers. Examples: [index1 index2] = nearestNumbers([2 5 3...

6 mois ago

Solved

Target sorting

Sort the given list of numbers |a| according to how far away each element is from the target value |t|. The result should return...

6 mois ago

Solved

Which values occur exactly three times?

Return a list of all values (sorted smallest to largest) that appear exactly three times in the input vector x. So if x = [1 2...

6 mois ago

Solved

Return the largest number that is adjacent to a zero

This example comes from Steve Eddins' blog: <http://blogs.mathworks.com/steve/2009/05/27/learning-lessons-from-a-one-liner/ Lear...

6 mois ago

Solved

Simple equation: Annual salary

Given an hourly wage, compute an annual salary by multiplying the wage times 40 and times 50, because salary = wage x 40 hours/w...

6 mois ago

Solved

Sort a list of complex numbers based on far they are from the origin.

Given a list of complex numbers z, return a list zSorted such that the numbers that are farthest from the origin (0+0i) appear f...

6 mois ago

Solved

Summing digits

Given n, find the sum of the digits that make up 2^n. Example: Input n = 7 Output b = 11 since 2^7 = 128, and 1 + ...

6 mois 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...

6 mois 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...

6 mois 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...

6 mois ago

Solved

Find the numeric mean of the prime numbers in a matrix.

There will always be at least one prime in the matrix. Example: Input in = [ 8 3 5 9 ] Output out is 4...

6 mois ago

Solved

Weighted average

Given two lists of numbers, determine the weighted average. Example [1 2 3] and [10 15 20] should result in 33.333...

6 mois ago

Solved

Remove any row in which a NaN appears

Given the matrix A, return B in which all the rows that have one or more <http://www.mathworks.com/help/techdoc/ref/nan.html NaN...

6 mois ago

Solved

Who Has the Most Change?

You have a matrix for which each row is a person and the columns represent the number of quarters, nickels, dimes, and pennies t...

6 mois ago

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...

6 mois ago

Solved

Remove the vowels

Remove all the vowels in the given phrase. Example: Input s1 = 'Jack and Jill went up the hill' Output s2 is 'Jck nd Jll wn...

6 mois ago

Solved

Make a checkerboard matrix

Given an integer n, make an n-by-n matrix made up of alternating ones and zeros as shown below. The a(1,1) should be 1. Examp...

6 mois ago

Solved

Find all elements less than 0 or greater than 10 and replace them with NaN

Given an input vector x, find all elements of x less than 0 or greater than 10 and replace them with NaN. Example: Input ...

6 mois ago

Solved

Determine if input is odd

Given the input n, return true if n is odd or false if n is even.

6 mois ago

Solved

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 ...

6 mois 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...

6 mois ago

Solved

2D - Mean Filter

Assume you are given an "image" matrix of size NxM. Reduce the image noise by implementing a mean filter window of size 9 (a 3x3...

6 mois ago

Solved

Sum of the pixel values for the blue color

Calculate the sum of the pixel values for the blue color, with a picture as an input. *NOTE:* The picture will be provided as...

6 mois ago

Solved

Create an 8-color version of an image

This problem was inspired by a tweet I saw from @MATLAB regarding <http://www.mathworks.com/matlabcentral/fileexchange/37816-the...

6 mois ago

Solved

Create different color vectors.

When producing figures with multiple lines on, you often want the lines to all be visible and different colors. Given the need f...

6 mois 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...

6 mois ago

Solved

Make blocks of color

Given a (Nx3) sequence of RGB colors, I want to create a (numRowBlocks x numColBlocks x 3) image comprising (blockSize x blockSi...

6 mois ago

Solved

RGB to CMYK

Convert an RGB code to the corresponding CMYK code for printing. The RGB input is a [1×3] double array between 0 and 1. ...

6 mois ago