Stairs
Make an n by n matrix, where the elements are ones and zeros. In the main diagonal, and under that, there should be only ones (...
5年弱 前
解決済み
Vectorize the digits of an Integer
Create a vector of length N for an integer of N digits.
x = 123045;
x_vec = [1 2 3 0 4 5];
I happened upon a trick ...
Select every other element of a vector (★★)
(copy of prob 6)
Write a function which returns every other element of the vector passed in. That is, it returns the all odd-...
5年弱 前
解決済み
Sum of elements of a vector (★★★)
Given any vector x = [x1, x2, x3, ... xn], compute the sum of its elements.
Thus, if x = [ 1 3 -2 5 ], then the sum of its el...
Variance computation (★)
Given a vector x with several values, compute the variance, whose formula is given by:
<<https://i.imgur.com/Wg95KBE.gif>>
...
Vector raised to a power, element-wise (★)
Given a vector A and a number x, raise each element of the vector to the power of x. Thus, if A = [2 5 7 1] and x = 0.5, then
...
Doubling elements in a vector (★★)
(copy of prob. 1024)
Given the vector A, return B in which all numbers in A are doubling. So for:
A = [ 1 5 8 ]
t...
5年弱 前
解決済み
Element-wise vector product (★)
Given two vectors x and y, compute their element-wise product z.
Thus, if x = [1 3 5] and y = [0.5 -1 2], then
z = [1*0.5...