Question

Using MATLAB Write a user-defined MATLAB function for the following math function: y(x)= (-0.2x^3 + 7x^2)e^-0.3x...

Using MATLAB

Write a user-defined MATLAB function for the following math function:

y(x)= (-0.2x^3 + 7x^2)e^-0.3x

The input to the function is x and the output is y. Write the function such that x can be a vector (use element-by-element operations).

(a) Use the function to calculate y(-1.5) and y(5).

(b) Use the function to make a plot of the function y(x) for -2 ≤ x ≤ 6.

Homework Answers

Answer #1

The first step is to define the function for the given equation

function y=fun(x)
y=(-0.2*x.^3+7*x^2).*exp(-0.3*x);   
end

a) Then you have to give the input of x as given in the question -1.5 and 5 respectively and you will gett the answer as

>> fun(-1.5)

ans =2 5.7595

>>fun(5)

ans = 33.4695

b) Then to plot the function we use the code

x=linspace(-2, 6, 500);

y=fun(x);

plot(x,y)

xlabel('x')

ylabel('y')

Which gives us the following graph

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
10.16: Write a user-defined MATLAB function that solves a first-order ODE by applying the midpoint method...
10.16: Write a user-defined MATLAB function that solves a first-order ODE by applying the midpoint method (use the form of second-order Runge-Kutta method, Eqs(10.65),(10.66)). For function name and arguments use [x,y]=odeMIDPOINT(ODE,a,b,h,yINI). The input argument ODE is a name for the function that calculates dy/dx. It is a dummy name for the function that is imported into odeMIDPOINT. The arguments a and b define the domain of the solution, h is step size; yINI is initial value. The output arguments, x...
Write a user-defined function, in MATLAB, with function call val=evalf(f,a,b) where f is an inline function,...
Write a user-defined function, in MATLAB, with function call val=evalf(f,a,b) where f is an inline function, and a and b are constants such that a<b. The function calculates the midpoint m of the interval [a,b] and returns the value of (1/2)f(a)+(1/3)f(m)+(1/4)f(b). Execute the function for f(x)=e^(-x)*cos(2x), a=-1, b=3.
Using Matlab to solve the problem below Given X=[-2 -1 0 1 2] Y=[1.5 3.2 4.5...
Using Matlab to solve the problem below Given X=[-2 -1 0 1 2] Y=[1.5 3.2 4.5 3.4 2] a). Plot a scatter plot of the data b). Determine the coefficients of the polynomial ?0 + ?1? + ?2?2 which best fits the data c). Plot this function on the same plot as in part ‘a’. USE MATLAB CODE ONLY! USE MATLAB CODE ONLY! THANK YOU
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that...
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that implements the bisection method. You function should take as input 4 arguments with the last argument being optional, i.e, if the user does not provide the accuracy tol use a default of 1.0e-6 (use varargin to attain this). Your function should output the approximate root, approx_root and the number of iterations it took to attain the root, num_its. However, if the user calls the...
Write a MATLAB function that implements the difference equation for the system assuming null initial conditions....
Write a MATLAB function that implements the difference equation for the system assuming null initial conditions. Include source code . y(n) = x(n) + 2x(n-1) + x(n-2) + 0.8 y(n-1) - 0.64 y(n-2) Use Matlab to calculate the response of the system to p(n) = 0 for all n expect when p(10) = 1. Using stem, plot the resulting output to n=100 What is the amplitude of the output squence? Was the signal amplified? How much?
Write a MATLAB code to plot a contour graph of f(x, y) = x^2 + y^2...
Write a MATLAB code to plot a contour graph of f(x, y) = x^2 + y^2 for −2 ≤ x ≤ 2 and −3 ≤ y ≤ 3. Use the interval of 0.1 in the grid.
Write a MATLAB function function [ AvgPos, AvgNeg ] = PosNegAverage ( X ) that calculates...
Write a MATLAB function function [ AvgPos, AvgNeg ] = PosNegAverage ( X ) that calculates average of positive, AvgPos, and negative, AvgNeg, elements of array X, using the for‐end loop and if‐elseif‐else‐end selection structure. Do not use build‐in MATLAN functions in calculations. Apply the developed function for the following vector X = [ ‐7, 1, 0, 0, 12, 6, 33.2, ‐7.5 ];
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads data from a file and performs regression analysis using polyfit and polyval. The function shall have the following features: The input arguments shall include the file name (string), a vector of integers for the degrees of polynomial fits to be determined, and an optional plot type specifier (‘m’ for multiple plots, ‘s’ for a single plot - default). The data files will be text...
] Consider the function f : R 2 → R defined by f(x, y) = x...
] Consider the function f : R 2 → R defined by f(x, y) = x ln(x + 2y). (a) Find the gradient of f(x, y) at the point P(e/3, e/3). (b) Use the gradient to find the directional derivative of f at P(e/3, e/3) in the direction of the vector ~u = h−4, 3i. (c) Find a unit vector (based at P) pointing in the direction in which f increases most rapidly at P.
MATLAB: Write a function called matrix_problem1 that takes a matrix A of positive integers as its...
MATLAB: Write a function called matrix_problem1 that takes a matrix A of positive integers as its sole input. If the assumption is wrong, the function returns an empty matrix. Otherwise, the function doubles every odd element of A and returns the resulting matrix. Notice that the output matrix will have all even elements. For example, the call B = matrix_problem([1 4; 5 2; 3 1], will make B equal to [2 4; 10 2; 6 2]. The function should work...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT