MATLAB: Plotting two linear equations equationlinearplot Hi. How can i plot this equation between (-5,2) values f(x) = -1 —-> x<-1 x^2+x ——> -1 <= x < 2 Best Answer Use ‘logical indexing’:x = linspace(-5,2);f = @(x) (-1).*(x < -1) + (x.^2 + x).*((x >= -1) & (x < 2));figure(1)plot(x, f(x))grid Related SolutionsMATLAB: What is the mistake syms xA=[x 2 1;1 0 -x;5 1 x];x=-15:.1:15;plot(x,subs(det(A),x))grid on MATLAB: Can’t i plot this equation Use element-wise divide operator ./ instead of matrix divide operator /f=@(x)((1+x.^2-1.5*x.^3+0.5*x.^4)./(1+x.^4)) Related QuestionPlot function over two intervalsHow can i solve non-linear equationAm I getting an error “vectors must be the same length”Is the plot not showing
Best Answer