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 logical indexing (do not use loops)
`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.
Get Answers For Free
Most questions answered within 1 hours.