MATLAB: How to plot a piecewise function functionifif statementplotplot using ifstatement Best Answer Solution usin if statement:x=linspace(-5,30,1000);for i=1:1000if x(i)<0 y(i)=10;elseif x(i)>=0 & x(i)<9y(i)=10*x(i)+10; else y(i)=15*sqrt(4*x(i))+10;endendplot(x,y) Related SolutionsMATLAB: I am getting a straight line while running the following code. What is going wrong? x=0.1:0.001:10;y=exp(-x.^2/2)./sqrt(x);plot(x,y)It's ./ instead of / MATLAB: Adjusting data points that fit a criteria x = 1:1:100; y = x; x(x>10 & x<20) = x(x>10 & x<20)+1; plot(x,y)If you want a new variable x1 = x; x1(x1>10 & x1<20) = x1(x1>10 & x1<20)+1; plot(x1,y) Related QuestionHow to modify function assignment of plotCan’t plot function
Best Answer