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 ...
約4年 前
解決済み
Weighted average
Given two lists of numbers, determine the weighted average as follows
Example
[1 2 3] and [10 15 20]
should result in
33.3...
約4年 前
解決済み
What number has this problem?
This problem is added because it is problem number *???* in the "Community" problems section.
<http://www.mathworks.de/matlab...
約4年 前
解決済み
Swap two numbers
Example
Input:
a = 10
b = 20
Output
a = 20
b = 10
Distance walked 1D
Suppose you go from position 7 to 10 to 6 to 4. Then you have walked 9 units of distance, since 7 to 10 is 3 units, 10 to 6 is 4...
約4年 前
解決済み
Compare two input matrices
Check which input matrix has more elements. Return "1" if matrix A has more elements than matrix B. Otherwise return "0".
Exa...
Replicate elements in vectors
Replicate each element of a row vector (with NaN) a constant number of times.
Examples
n=2, A=[1 2 3] -> [1 1 2 2 3 3]
...
約4年 前
解決済み
Square the input
Given a scalar or vector x, return the square of each element.
Example
x = [7 2]
answer = [49 4]
Deleting an element in a matrix
For vector Grades=[98 56 78 34 100 88 87], delete the number 78 to get the following matrix
Grades=[98 56 34 100 88 87]
**re...
約4年 前
解決済み
Square a Number
Given an input x, return y, which is equal to the square of x.
約4年 前
解決済み
Return 'on' or 'off'
When the input is true, return 'on', otherwise, return 'off'.
約4年 前
解決済み
Angle between Two Vectors
The dot product relationship, a dot b = | a | | b | cos(theta), can be used to determine the acute angle between vector a and ve...
約4年 前
解決済み
Sum of first n positive integers
Given n, find the sum of first n positive integers
Example: If n=10, then x=1,2,3,4,5,6,7,8,9,10. The sum of these terms is 55
約4年 前
解決済み
Angle between two vectors
You have two vectors , determine the angle between these two vectors
For example:
u = [0 0 1];
v = [1 0 0];
The a...
約4年 前
解決済み
ASCii Code
Using matlab, give the symbol that is associated with ASCii code 122
Sum of digits of powers of 2
Given n, first, calculate the number 2^n. Then, sum the digits that comprise that number. For example:
Input: n = 7
2^n = ...
約4年 前
解決済み
There are 10 types of people in the world
Those who know binary, and those who don't.
The number 2015 is a palindrome in binary (11111011111 to be exact) Given a year...