Community Profile

Contact

Top 5% contributor

Does your mxArray happen to contain a Java object? I recently discovered the hard way that calling |mxDestroyArray()| on an mxA...

0

Answered 2 years ago

Based on the original question and replies, it's not clear whether you are calling C code from MATLAB (a MEX file) or executing ...

4986 views

Responded 4 years ago

Write a function posX=findPosition(x,y) where x is a vector and y is the number that you are searching for. Examples: fin...

Solve this!

3 years ago

Given a vector of numbers, return true if one of the numbers is a square of one of the other numbers. Otherwise return false. E...

Rotate input matrix (which will be square) 90 degrees counter-clockwise without using rot90,flipud,fliplr, or flipdim (or eval)....

Calculate the area of a triangle between three points: P1(X1,Y1) P2(X2,Y2) P3(X3,Y3) these three points are the vert...

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

Return an array of numbers which (effectively) count from 0 to N^M-1 in base N. The result should be returned in a matrix, with ...

Given a collection of points, return the indices of the rows that contain the two points most distant from one another. The inpu...

Given a string s1, find all occurrences of the single quote character and replace them with two occurrences of the single quote ...

Example: in = magic(5) in = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 ...

inner product of two vectors

Given a handle fh to a function which takes a scalar input and returns a scalar output and an integer n >= 1, return a handle f...

<http://en.wikipedia.org/wiki/Benford%27s_law Benford's Law> states that the distribution of leading digits is not random. This...

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

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

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

At one time or another, we all had to memorize boring times tables. 5 times 5 is 25. 5 times 6 is 30. 12 times 12 is way more th...

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

Given an integer n >= 0, generate the length n+1 row vector representing the n-th row of <http://en.wikipedia.org/wiki/Pascals_t...

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

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

Calculate the nth Fibonacci number. Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ... Examples: Inpu...

Return true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return f...

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

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

Flip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All oth...

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

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

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

Load more