Top 5% contributor
Thanks for the three solutions. Here is a function to test all three. "method_1" wins as the most elegant and fastest, but the o...
Answered 5 years ago
Given two vectors A and B, find the index, idx into A of the element of B so that
Now I know there must be many ways...
Asked 5 years ago
So the follow-up question would be why are trailing singleton dimensions ignored? I have a test case where I supply a 3D matrix ...
5 years ago
Why does ndims(zeros(1,1,1)) equal 2 and not 3?
5 years ago
Thinking again, I realize that ismember is all I need
will do it.
Say I have an image which I plot in a figure and print that figure to a .tiff file. The original image has size [257,250] T...
7 years ago
For the following code
the MATLAB Editor Code Analyzer warns
"The value assigned to var...
Asked 4 years ago
6 years ago
I am plotting multiple sets of data on the same axes with set 1 in blue and set 2 in green and would like to make a legend with ...
10 years ago
Un undocked editor window has the full path long filename to the file being edited in the title of the window. For long paths, t...
When compiling some C-code using mex I get this error. error: expected expression before ‘/’ token Any suggestions...
8 years ago
Given vectors x and y each with N elements, I want to create an N element structure s with fields s.x and s.y. I can do this by ...
6 years ago
How could I find the most efficient FFT size greater than N? I know that with fftw "sizes that are products of small factors are...
I am looking for a way to start MATLAB from the command line, with all the gui stuff, so that MATLAB's current working directory...
11 years ago
I have a power signal that is strictly positive. I'd like to low-pass filter it, retaining the positive property. I know I can u...
I have been playing around, in MATLAB 2012b, with setting the fonts in a Figure. I have done this both under OS X and Windows 7,...
Sort the given list of numbers |a| according to how far away each element is from the target value |t|. The result should return...
4 years ago
This example comes from Steve Eddins' blog: <http://blogs.mathworks.com/steve/2009/05/27/learning-lessons-from-a-one-liner/ Lear...
The <http://en.wikipedia.org/wiki/Goldbach's_conjecture Goldbach conjecture> asserts that every even integer greater than 2 can ...
You have a matrix for which each row is a person and the columns represent the number of quarters, nickels, dimes, and pennies t...
Remove all the vowels in the given phrase.
Input s1 = 'Jack and Jill went up the hill'
Output s2 is 'Jck nd Jll wn...
Given n, find the sum of the digits that make up 2^n.
Input n = 7
Output b = 11
since 2^7 = 128, and 1 + ...
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...
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...
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...
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 the matrix a, return the index r of the row with the most nonzero elements. Assume there will always be exactly one row th...
There will always be at least one prime in the matrix.
Input in = [ 8 3
5 9 ]
Output out is 4...
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...
Given a vector of numbers, return true if one of the numbers is a square of one of the other numbers. Otherwise return false.
Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a location from the following list:
See all countries