Function script:
function fnfn_plot(f1,f2)
x=rand(1,100);
x=sort(x);
y1=f1(x);
y2=f2(x);
figure;
plot(x,y1);grid;xlabel('x');ylabel('y1(x)');title('Sqrt(x)')
figure;
plot(x,y2);grid;xlabel('x');ylabel('y2(x)');title('exp(x)')
end
________________________________________________________________________
>>fnfn_plot(@sqrt,@exp);
The matlab code for the following problem is appreciated!! QUESTION 3 Write a function fnfr_plot that...
it is c++ for question 2 it has multiple parts QUESTION 2 Write a program to generate N 20 random number in between 0 to N and [Q2] sort then descending [Q3jand ascending [Q4]Now define vector int> even to put the sorted evens [Q5]convert the sorted even in a range of 0 to 2*M_PI and print out their sind 1/ you might upload ans as different files or just one file Attach File Browse My Computer Browse Content Collection Browse...
*MATLAB CODE* 3)Write a function 'mydsort' that sorts a vector in descending order (using a loop, not the built-in sort function). 4)write a function that will receive a vector and will return two index vectors: one for ascending order and one for descending order. Check the function by writing a script that will call the function and then use the index vectors to print the original vector in ascending and descending order. **Please make sure they work. I have found...
Please use MatLab and comment code. Problem 2 Write a MATI AB user-defined function y-M?SotxType): x is a vector containing numbers. and Type can be 'Ascending' or Descending'. This function should sort the given vector x in the ascending or descending order based on the user's request and return the desired vector as the output. Do not use MATLAB built-in function sort. Hint: When you call this function you need to use for Ascending or Descending since they are strings.
Question 1: Creating a user-defined function Write a user-defined MATLAB function named PBTask4pl_f.m for the following math function with x the input argument and y the output y(x)=0.8x4-13x2-5x The function should work for x being a scalar or a vector. Write a script file named PBTask4pl.m to a) Use the function to calculate y(3) and y(5) and display the results in command window b) Use the function to make a plot of the function y(x) for -5:5: x 5:5. Label...
Consider the function f(x) = x3 – 2x2 + x Write the MATLAB code in the format of "script file" using "Regula Falsi Method" with the estimated relative error of 0.000001 and upload the script file. Direction: 1) Please submit"script file", NOT "function file". If you submit a function file, I will assign ZERO score. 2) You can find some matlab code for the Regula Falsi Method on a web or some books. You can use any code you can...
Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y = sin(x) from x = 0 to 21. 12) Plot the functions y = x2 z = x2 + 2x + 1 from x = 0 to 2 on the same graph. Scripts: Input and Output 13) Write a script (M-file) to read in a message at the command line using the MATLAB input function and then display the message to the Command Window using...
MATLAB Problem HW7P2 (20 points) (5 pts) Write a user-defined MATLAB function called HW7P2_fn for the following math function 3 o-0.47x The input to the function is x and the output is y. Write the function such that x can be an array (use element-by-element operations) (15 pts) Use the function in (a) the command window to calculate y(-2) and y(5) (b) a script file HW7P2.m to determine y(x) for 0.001 Sx S 10 with 1000 points. Hint: Use the...
Only calculate manually 1. Write a short MATLAB script or function (m-file) that generates the functions (t)eu(t) for a = 0.1. Plot the value of x(t). Since the e-af almost attenuates to 0 after 5T, where T1. So make your time vector from 0 to 5T would be enough to capture the signal.) 2. Using the definition of the FT (1), manually calculate the FT of the given functions in previous exercise 0O x(t)e 3. Plot the absolute values and...
submitting Script files and function files 3. Write MATLAB code to solve the following system of linear equations. Display the value of each variable (eg. "x= 1, y = 2, and z = 3). (15 points) hy - 4z=6 5x - 7y + 3z--2 x - 2y = 0
P2) Write a MATLAB function myLinReg Username that is defined below. Use the in-built MATLAB function sum( ) to ease your programming (you are NOT allowed to use polyfit() and polyval()). Test the output of this function with the results obtained by hand for P1. Submit printout of program and a screenshot of the command window showing the results for P1. function [coeffvec, r2]-myLinReg_Username (xi,yi) %Function file: myLinReg-Username .m Purpose : 8 To obtain the parameters of a L.S. linear...