MATLAB Script File:
close all
clear
clc
fprintf('y(x = -5) = %f\n', func(-5))
fprintf('y(x = 3) = %f\n', func(3))
fprintf('y(x = 15) = %f\n', func(15))
function y = func(x)
if x < -1
y = exp(-x+1);
else
if x >= -1 && x < 5
y = 2*sin(pi*x);
else
if x >= 5
y = 10*(x-5)+1;
end
end
end
end
Output:
y(x = -5) = 403.428793
y(x = 3) = 0.000000
y(x = 15) = 101.000000
10) you will run/call the function with these given values. (b) Write a flow chart and the script file using conditional statements with logical operator if/else and if/elseif, to evaluate the fo...
3. (a) Write a flow chart and the script file using for loop and conditional statements to evaluate and plot the folowing function, assuming that the salar x has a valiue: for x <-1 ys20yx + 6 y = 8x sin(2πχ) for-1 < x < 5 y=15(x-1) + 1 for x 25
3. (a) Write a flow chart and the script file using for loop and conditional statements to evaluate and plot the folowing function, assuming that the salar x...
2. (aj An object thrown vertically with a speed vo reaches a height h at time t,where with a user defined function that computes the time required to reach a Write a MATLAB program specified height h, for a given value of vo. The function's imput should be h, we and g Testverurtrott" for the case where h-100 m, vee50 m/s and g-9,82 /by free hand. Write the MATLAB you will run/call the function with these given values (b) Write...
2. (a) An object thrown vertically with a speed vo reaches a height h at time t, where: he vot tgt Write a MATLAB program with a user defined function that computes the time required to reach a specified height h, for a given value of vo. The function's input should be h, Vo, and g. Test your function for the case where h 100 m, Vo-50 m/s and g9,81 m/s2 by free hand. Write the MATLAB command how you...
matlab only
Question 5: a.) Write an m-file using conditional statements to evaluate the following function, assuming that the scalar variable x has a value. The function is for x <-1 - 3e y=2+cos(m) for-1 x<5 y 10-5)+1 for r 2 5 Use your file to evaluate y for x5, x-3, and x-15, and Use keyboard entry for values of x. b.) Use a for loop in the above file to plot the above function over the interval -2x <10....
Matlab Question (Matlab Grader) Where indicated at the bottom of the script. write a function, called isright, that takes three inputs, a, b, and c, and determines whether they are could be the lengths of the sides of a right triangle; the output, y, will be set equal to the following: i). -1 if at least one of the values is not positive. Also, only for this case, have the function print out an error message, which states "At least...
Flow CHART READ THIS PROGRAM OVER SEVERAL TIMES vI: Flow chart the problem that follows. DO NOT WRITE THE CODE. Your grade will depend on how well you show cosmology the behavior of space through time is given by a function called the scale factor r(t). The variable,t, i behaviors of the scale factor depending upon estimates of the amount of matter in the universe. The amount of rogrom will start by asking the user for the epsilon value only...
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...
READ THIS PROGRAM OVER SEVERAL TIMES VI: (10 pts) Flow chart the problem that follows. DO NOT WRITE THE CODE. Your grade will depend on how well you show that the flow chart represents the structure of this program and basic calculations and logical expressions are represented in the flow chart(show formulas used below in the chart) and proper flowchart symbols are used. In cosmology the behavior of space through time is given by a function called the scale factor...
1)
a) Write MATLAB function that accepts a positive integer
parameter n and returns a vector containing the values of the
integral (A) for n= 1,2,3,..., n. The function must use the
relation (B) and the value of y(1). Your function must preallocate
the array that it returns. Use for loop when writing your code.
b) Write MATLAB script that uses your function to calculate the
values of the integral (A) using the recurrence relation (B), y(n)
for n=1,2,... 19...