Question

In: Mechanical Engineering

Use a for loop to plot the function given in Problem 16 over the interval -2 ≤ x ≤ 6. Properly label

Use a for loop to plot the function given in Problem 16 over the interval -2 ≤ x ≤ 6. Properly label the plot. The variable y represents height in kilometers, and the variable x represents time in seconds.

Solutions

Expert Solution

Program plan:

• To write a matlab code that using for loop to plot the piece wise function in the conditional statement.

 

Program:

%**********************************************************

%A matlab code to plot the piece wise function using the

%for loop for the given range of ‘x’.

%**********************************************************

%Program Code

%Declaration of the array

x=[-2:0.1:6];

for (i=1:length(x)) %Initialization of for loop

if (x(i)<-1) %Conditional statement

%Computes the value

y(i)=exp(x(i)+1);

elseif (x(i)>=-1)&(x(i)<5) %Conditional statement

%computes the value

y(i)=2+cos(pi*x(i));

else %Default statement

%Computes the value

y(i)=10*(x(i)-5)+1;

end %End of conditional statement

end %End of for loop

%Plotting the piece wise function

plot (x,y);

%Assigns text to x-axis

xlabel(\'Time in seconds\');

%Assigns text to y-axis

ylabel(\'Height in kilometers\');

 

Output:

 


Related Solutions

Plot the function y = 10(1 = e-x/4) over the interval 0 ≤ x ≤ xmax, using a while loop to
Plot the function y = 10(1 = e-x/4) over the interval 0 ≤ x ≤ xmax, using a while loop to determine the value of xmax such that y(xmax) = 9.8.Properly label the plot. The variable y represents force in newtons, and the variable x represents time in seconds.
Expand the function, f(x) = x, defined over the interval 0 <x <2, in terms of:...
Expand the function, f(x) = x, defined over the interval 0 <x <2, in terms of: A Fourier sine series, using an odd extension of f(x) and A Fourier cosine series, using an even extension of f(x)
Use MATLAB to plot the functions u = 2 log10(60x + 1) and υ = 3 cos(6x) over the interval 0 ≤ x ≤ 2.
Use MATLAB to plot the functions u = 2 log10(60x + 1) and υ = 3 cos(6x) over the interval 0 ≤ x ≤ 2. Properly label the plot and each curve. The variables u and represent speed in miles per hour; the variable x represents distance in miles.
Random variable X is uniformly distributed over the interval [2, b]. Given: P { |X –...
Random variable X is uniformly distributed over the interval [2, b]. Given: P { |X – 4 | > 4} = 0. 8. a) Find P { 0 < X < 5}
Sketch the linearized Bode plots of system function given below. Ensure to properly label the graph....
Sketch the linearized Bode plots of system function given below. Ensure to properly label the graph. H(s) = 10^9 (s + 100)(s + 1000) / (s^2 + 15000s + 100 × 10^6)(s + 100 × 10^3)
Find the lengths of the functions of x over the given interval.
Find the lengths of the functions of x over the given interval.
The average value of a function f over the interval [-2,3] is -6, and the average...
The average value of a function f over the interval [-2,3] is -6, and the average value of f over the interval [3,5] is 20. What is the average value of f over the interval [-2,5]?
use the given zero to find the remaining zeros of each polynomial function 23. f(x)=x^3-4x^2+4x-16; zero;...
use the given zero to find the remaining zeros of each polynomial function 23. f(x)=x^3-4x^2+4x-16; zero; 2i 27. x^4-9x^3+21x^2+21x-130; zero: 3-2i Find the complex zeroes of each polynomial function. Write f in factored form. 35. f(x)=x^4+5x^2+4 I tried using Descarte's rule for questions 23 and 27, but I don't what to do after that. Also, after you explain the steps I need to solve the question, could you help understand why these steps are necessary?
Consider the function f(x)=arctan [(x+6)/(x+5)] Express the domain of the function in interval notation: Find the...
Consider the function f(x)=arctan [(x+6)/(x+5)] Express the domain of the function in interval notation: Find the y-intercept: y= . Find all the x-intercepts (enter your answer as a comma-separated list): x= . Does f have any symmetries? f is even; f is odd; f is periodic; None of the above. Find all the asymptotes of f (enter your answers as comma-separated list; if the list is empty, enter DNE): Vertical asymptotes: ; Horizontal asymptotes: ; Slant asymptotes: . Determine the...
Consider the function f(x)=arctan [(x+6)/(x+5)] Express the domain of the function in interval notation: Find the...
Consider the function f(x)=arctan [(x+6)/(x+5)] Express the domain of the function in interval notation: Find the y-intercept: y= . Find all the x-intercepts (enter your answer as a comma-separated list): x= . Does f have any symmetries? f is even; f is odd; f is periodic; None of the above. Find all the asymptotes of f (enter your answers as comma-separated list; if the list is empty, enter DNE): Vertical asymptotes: ; Horizontal asymptotes: ; Slant asymptotes: . Determine the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT