MATLAB Question: Write a function check_even that takes any number as input and outputs logical 1 if it's an even number and 0 otherwise.
Your answer must contain only the function definition (that is, nothing should come before function or after end. The automatic grading will then try a number of different inputs to your function, to test whether it works correctly. Don't forget to write some help text for your function!
A Pythagorean triple is a set of positive integers (a, b, c) such that a^2 + b ^2 = c^2. Write a function is_pythag_triple that will receive three positive integers (a, b, c, in that order) and will return logical 1 (for true ) if they form a Pythagorean triple, or 0 (for false ) if not.
Your answer must contain only the function definition (that is, nothing should come before function or after end. The automatic grading will then try a number of different inputs to your function, to test whether it works correctly. Don't forget to write some help text for your function!
Write a function gen_fibo that will output a vector with the first n numbers of the Fibonacci sequence.
Hint: Use the pseudocode below as a starting point!
Your answer must contain only the function definition (that is, nothing should come before function or after end. The automatic grading will then try a number of different inputs to your function, to test whether it works correctly. Don't forget to write some help text for your function!
Untitled
function fibo_vec = gen_fibo(n)
n = input_arg % get the length of the sequence
% initialize start of sequence
number1 = 1
number2 = 1
% If we want one number
'assign number1 to first element of output vector'
% If we want two numbers
'assign number1 to first element of output vector'
'assign number2 to 2nd element of output vector'
% Take care of the other numbers:
'IF there is still one or more numbers to print'
'Repeat FOR each number that is left'
% compute+print new number
new_num = number1 + number2
'assign new number to next element in output vector'
% update the two numbers
number1 = number2;
number2 = new_num;
end