Question

Create an entire array and using for loops. Define a vector x over the range of...

Create an entire array and using for loops. Define a vector x over the range of -10 to 10 with a resolution of 1000 points. Then, please write requested MATLAB scripts to plot the piecewise function (note: plot(x,y) is sufficient, DO NOT USE fplot):

y=?, ? < −5
? = −3, −5 ≤ ? ≤ 0

y=?^2, 0<?<5

y=7, ?≥5

  1. Use logical indexing (do not use loops)

Homework Answers

Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc
clear all
close all
format long
x=linspace(-10,10,1000);
y=(x<-5).*x+(x>=-5&x<=0).*(-3)+(x>0&x<5).*(x.^2)+7*(x>=5);
plot(x,y);

Kindly revert for any queries

Thanks.

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
Create an entire array and using for loops. Define a vector x over the range of...
Create an entire array and using for loops. Define a vector x over the range of -10 to 10 with a resolution of 1000 points. Then, please write requested MATLAB scripts to plot the piecewise function (note: plot(x,y) is sufficient, DO NOT USE fplot): y=?, ? < −5 ? = −3, −5 ≤ ? ≤ 0 y=?^2, 0<?<5 y=7, ?≥5 Use nested if statements (with a for loop)
1. Now generate y array using the function file my_func for the x array varying from...
1. Now generate y array using the function file my_func for the x array varying from 0 to 4 with an increment of 0.2. Generate x and y arrays without using any loop statement and do not print these arrays. 2. Off of question 1. Using MATLAB plot routine, plot y-array against the x-array generated in question 1. On this plot show grid lines, label the axes as x and y, and write the text ‘y=f(x)’ next to the plotted...
Using MATLAB The range of an object shot at an angle θ (with respect to x-axis),...
Using MATLAB The range of an object shot at an angle θ (with respect to x-axis), with the initial velocity of V0 (in the absence of air resistance), is calculated by the following formula: range=(Vo^2/g)(sin(2theta)) where (0<=theta<=pi/2) And the trajectory of object is given by:     h=tan(theta).x-(g/2Vo^2*cos^2(theta)).x^2 .Where h is the height of the object at each x location and g = 9.81 m/s2. a) Using π/8 increment size for the angle and V0 = 10 m/s, plot the trajectories of...
let us create a variable for a row vector a = [1, 4, 1, 3, 2,...
let us create a variable for a row vector a = [1, 4, 1, 3, 2, 5, 0] and calculate the mean value of its elements using the Matlab function ‘mean’ and store this value in variable aMean. Fig. 1 gives the Matlab code to do this. a = [1, 4, 1, 3, 2, 5, 0]; aMean = mean(a); Figure 1: Matlab code – row vector and mean of its elements. Let us now construct a row vector b that...
Q) a) create a matrix named as X of evenly spaced values from 0 to 50,...
Q) a) create a matrix named as X of evenly spaced values from 0 to 50, with an increment of 10. b) a) create a matrix named as Y of evenly spaced values from 500 to 1000, with an increment of 3. c)a) create a matrix named as Z, the value of the 1st row is from 1 to 10, 2nd row from 2 to 20 with increment of 2, 3rd row 3 to 12. using subplot divide the window...
14. Practice questions a. Create an anonymous function called func1 for the dummy argument x that...
14. Practice questions a. Create an anonymous function called func1 for the dummy argument x that finds the exponential of the negative one-half times the argument, and multiplies it by the sine of five times the argument. If given a vector or matrix, the function should perform element-by-element processing. b. Using plot(), plot plotr -vs- func1(plotr) as a blue line. Then plot this same function again over the same range (0, 5) as a dashed red line using fplot(), keeping...
a) Define a function to be x^3+3x-4 and define another function to be x^2-5x+10. **Note: Use...
a) Define a function to be x^3+3x-4 and define another function to be x^2-5x+10. **Note: Use different names for each function. b) Plot both functions from part a on the same graph from x=-5 to x=5. Define a range of 0 to 100 with the PlotRange option. Use the PlotLegends option to label the functions with their "Expressions". You may need to refer to the "Lab 3 Functions Continued" instructional notebook or the Documentation Center to see how options are...
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...
PLEASE USE MAT LAB ONLY. THANK YOU (a) Create and plot the signals listed below and...
PLEASE USE MAT LAB ONLY. THANK YOU (a) Create and plot the signals listed below and save your Matlab code in a script file. i) Cosine signal of frequency 100 Hz over the range [0,0.1] seconds and samples spaced 10^- 4 seconds apart with a phase of pi/2 and an amplitude of 1.   PLEASE USE MAT LAB ONLY. THANK YOU ii) A square wave that oscillates between 0 and 1 every five samples, plot 3 periods of the waveform. iii)...
Using MatLab 2. Given the parametric equations x = t^3 - 3t, y = t^2-3: (a)...
Using MatLab 2. Given the parametric equations x = t^3 - 3t, y = t^2-3: (a) Find the points where the tangent line is horizontal or vertical (indicate which in a text line) (b) Plot the curve parametrized by these equations to confirm. (c) Note that the curve crosses itself at the origin. Find the equation of both tangent lines. (d) Find the length of the loop in the graph and the area enclosed by the loop. 3. Use what...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT