Reverse the vector
Reverse the vector elements.
Example:
Input x = [1,2,3,4,5,6,7,8,9]
Output y = [9,8,7,6,5,4,3,2,1]
4ヶ月 前
解決済み
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...
4ヶ月 前
解決済み
Length of the hypotenuse
Given short sides of lengths a and b, calculate the length c of the hypotenuse of the right-angled triangle.
<<https://i.imgu...
4ヶ月 前
解決済み
Triangle Numbers
Triangle numbers are the sums of successive integers. So 6 is a triangle number because
6 = 1 + 2 + 3
which can be displayed ...
4ヶ月 前
解決済み
Generate a vector like 1,2,2,3,3,3,4,4,4,4
Generate a vector like 1,2,2,3,3,3,4,4,4,4
So if n = 3, then return
[1 2 2 3 3 3]
And if n = 5, then return
[1 2 2 3 3 3 4...
4ヶ月 前
解決済み
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...
4ヶ月 前
解決済み
Finding Perfect Squares
Given a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.
Example...
Estimating Euler's (Oi-ler-z) Number
Euler's number is an irrational constant given by
Starting with x=0, count the number of times you can add a uniformly distrib...
4ヶ月 前
解決済み
Next Tribonacci Number
The "Tribonacci" sequence is an extension of the idea of the Fibonacci sequence:
That is, each new term is the sum of the thr...
4ヶ月 前
解決済み
Generate Tribonacci Sequence
The "Tribonacci" sequence is an extension of the idea of the Fibonacci sequence:
That is, each new term is the sum of the thr...
4ヶ月 前
解決済み
Generate Pascal's Triangle Matrix
Pascal's triangle is an arrangement of numbers where each value is the sum of the values adjacent to it in the previous row:
...
4ヶ月 前
解決済み
Interpolated Value Between Two Points
Given two points, and , a new location x, and a method "linear" or "cubic", return the value of a linear or cubic interpolant t...
4ヶ月 前
解決済み
A Binary Search
One way to locate a target value in a sorted array, is to use a binary search algorithm. Here, you test if the midpoint in the a...
4ヶ月 前
解決済み
Where the Four Corners Am I? (Vectorized)
NOTE: this problem is intended to build on problem #55960 ("Where the Four Corners Am I?"). You may wish to solve that problem f...
4ヶ月 前
解決済み
Where the Four Corners Am I?
The "Four Corners" region of the US is where Colorado, Utah, Arizona, and New Mexico all meet - the only place where four states...
4ヶ月 前
解決済み
Taylor Series
You can use a Taylor series to approximate common functions. The Taylor series for sin(x) is
Using only the first several te...
4ヶ月 前
解決済み
Calculate Angle From Axis
Given coordinates x and y, an axis ("X" or "Y"), and a direction ("cw" or "ccw", meaning clockwise and counterclockwise, respect...