Duplicates
Write a function that accepts a cell array of strings and returns another cell array of strings *with only the duplicates* retai...
約9年 前
解決済み
Remove all the words that end with "ain"
Given the string s1, return the string s2 with the target characters removed.
For example, given
s1 = 'the main event'
your ...
約9年 前
解決済み
Indexed Probability Table
This question was inspired by a Stack Overflow question forwarded to me
by Matt Simoneau.
Given a vector x, make an indexed pro...
約9年 前
解決済み
Summing Digits within Text
Given a string with text and digits, add all the numbers together.
Examples:
Input str = '4 and 20 blackbirds baked in a...
約9年 前
解決済み
Trimming Spaces
Given a string, remove all leading and trailing spaces (where space is defined as ASCII 32).
Input a = ' singular value deco...
約9年 前
解決済み
Angle of triangle
For three unknown points a b c, given three sides ab bc ca, find three angles abc bca cab in radians.
Your function should b...
約9年 前
解決済み
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 ...
約9年 前
解決済み
Finding Perfect Squares
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...
約9年 前
解決済み
Create times-tables
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...
約9年 前
解決済み
Fibonacci sequence
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...
The Goldbach Conjecture
The <http://en.wikipedia.org/wiki/Goldbach's_conjecture Goldbach conjecture> asserts that every even integer greater than 2 can ...
約9年 前
解決済み
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...
Triangle Numbers
Triangle numbers are the sums of successive integers. So 6 is a triangle number because
6 = 1 + 2 + 3
which can be displa...
約9年 前
解決済み
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 ...
約9年 前
解決済み
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...
Make the vector [1 2 3 4 5 6 7 8 9 10]
In MATLAB, you create a vector by enclosing the elements in square brackets like so:
x = [1 2 3 4]
Commas are optional, s...