Code:
file.m

new.m :

Output:

Raw Code:
new.m
y1 = @(x) 3 * x^2 + 5 ;
y2 = @(x) (12 * x )- (5 * x^2 ) ;
y3 = @(x) x^3 + 2*x^2 - ( 3 / ( x - x^2)) ;
a = file(y1,y2,y3,3)
b = file(y1,y2,y3,0)
c = file(y1,y2,y3,-2)
file.m
function y = file(e,f,g,x)
if (x>=2 && x<=5)
y = e(x);
elseif (x >= -0.5 && x < 2)
y = f(x);
elseif (x>= -3 && x < -0.5)
y = g(x);
end
end
If you have any doubts plz ask in comment section.
Create a function file that uses an if-else construct for the following piecewise function. The function...
C++ Create three recursive functions that accomplish the following: Recursive Power Function this function will raise a number to a power. The function should accept two arguments, the number to be raised and the exponent. Assume that the exponent is a non-negative integer. String Reverser function that accepts a string object as its argument and prints the string in reverse order. Sum of Numbers this function accepts an integer argument and returns the sum of all the integers from 1...
Using a while loop and if-else statements if required, write a function file that will add (sum) the DIGITS of any number entered. Your function should get the number (scalar) as an input 2. argument and return the sum as an output argument. You may use any of the following built-in functions to assist you: ceil, floor, round, fix, rem, or mod. HINT: What number do you need to divide by to get a single digit out of a long...
1. Write a MATLAB function that takes a matrix, a row number and
a scalar as
arguments and multiplies each element of the row of the matrix by
the scalar returning the
updated matrix.
2. Write a MATLAB function that takes a matrix, two row numbers and
a scalar as
arguments and returns a matrix with a linear combination of the
rows. For example, if the rows
passed to the function were i and j and the scalar was m,...
Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...
Create a CPP file for a C++ Program. Write exactly these functions, power(x,y) function and a print(text, number) function and the main() function. The power(x,y) function returns an integer result that is calculated by raising a number x (integer) to a power y (integer). The second argument y (exponent) of the function can not exceed 100. If the second argument exceeds 100, the function should return -1. Your power(x,y) function must be able to take either 1 or 2 integer...
Create a new file named spherevolume.py that does the following: Define a function named sphereVolume that accepts a radius value as an argument and returns (not prints) the volume of a sphere with that radius. Write code to test your function with the following inputs: sphereVolume(2.0) // should return 33.510321638291124 or a number close to it. sphereVolume(5.0) // should return 523.5987755982989 or a number close to it.
I was wondering how to do the following. This will all be in a header file to be called in a .cpp file. They all have to be template functions because the .cpp file will test a few different values for each function. This should be done in C++ ====== Write a variadic template for a function named problem5 that joins an arbitrary number of strings together. This function will serve as the terminating case for two strings and your...
Write a python program (recursive.py) that contains a main() function. The main() should test the following functions by calling each one with several different values. Here are the functions: 1) rprint - Recursive Printing: Design a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. 2) rmult - Recursive Multiplication: Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times...
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...