code :
function x= double(x) //function name is double and input
parameter is x and output variable name is also x
x=x+x; stroing added value to x
end
function calling:
val=2.0 //creating variable val
double(val) and caling double function with this value as
parameter
output:
ans=4.0
the compilation and execution will happen eventhough input variable name and output variable name is same:
in matlab Write and test a function double(x) which doubles its input argument, i.e., the statement...
Using MatLab Write a function called PrimeFinder that receives an integer n as an input argument, and provides an output argument called Primes that is a vector containing all prime numbers between 2 and n, inclusive. Verify the correctness of your code with inserting 13 as the input argument, and check that your output is Primes = [2,3,5,7,11,13]. You are NOT allowed to use any directly relevant MATLAB built-in function such as divisors, etc. NOTE: A prime number is a...
3. Write a function that receives an input argument x and returns y and z, which should be calculated as follows
b) (2.5 marks) Write a Matlab user defined function that takes the letter grades (i.e. AABBC) as input and returns if the student entitled to the honor list or not. The student is considered in the honor s f he or she satisfies the following three conditions: a. An average GPA of 3.5 and above and b. At least two classes with A mark and e. no class with a mark less than C (i.e. no D or F) The...
Using matlab Write a function that receives a vector as an input argument and prints the individual elements from the vector in a sentence format. One example of calling this function on the command window looks like >>printvec([1.12 23 9.245]) Element 1 is 1.12 Element 2 is 23.00 Element 3 is 9.25 1. (Note: your function should work for any vector.)
How will the function look in MATLAB? Write a function called plot_prop that takes an input value n. You need to plot a parabola i.e. a plot which ranges from a value to zero and then again from zero back to that value. Your parabola must be able to take any number (n) as an input. a) The line of the parabola is magenta and a solid line. b) The points of the parabola are starred. c) The X-axis is...
Write a Matlab function that argument of the function that represents the sam function that plots the following signal for O<t<700Ts (where Ts is the " that represents the sampling frequency) x(t) = 2n=-50 4k,sinc(t - nt's) where kn ( 1 if n = 0 Note: sinc(x)=sin(nx)/(xx) of n0
Matlab: Write a function called minimax that takes M, a matrix input argument and returns mmr, a row vector containing the absolute values of the difference between the maximum and minimum valued elements in each row. As a second output argument called mmm, it provides the difference between the maximum and minimum element in the entire matrix. See the code below for an example: >> A = randi(100,3,4) A = 66 94 75 18 4 68 40 71 85 76...
i need this done in Matlab 8. Write a function which reverses a vector, i.e. if the input is (4, 2, 1,5,-3], the output would be [-3,5, 1, 2,4]. 9. Write a function which computes the sum of every second element in a vector.
7. #4. 18 Following is a recursive function which takes as input (argument) a vector $x$ and returns a scalar. Either by looking carefully at the function, or by running the function with a few simple input vectors and observing the returned values in each case, determine what the function is doing. 29 00- "**{r} 01 - myfun=function(x){ 02 - if(length(x)=-1){return(x) C03 - } else 84 return(x[1]+my funcx[-1])) 205 - ) 206 myfun(c(1:1000)) #here's what happens when it is applied...
In matlab, there is a function "size" that accepts an array as a parameter (or input argument) and returns the dimensions of that array as another single-dimension array. For example, if the array were 2 x 2, it would return [2 2]. Assume that input1 is a 1 or 2-dimensional array. Use the size function to obtain the dimensions and save the output into the return argument of this function "output1" 1Do not modify the line below 2-unction...