Generating a Plot For a Function, HELP
Show older comments
When i go to run this code, it just keeps telling me to 'Enter a Value:' and will not show me any plot. I understand that this is my input, but i just want it to plot the values of x for (-10:10). Am i using the right commands?
function output=myfun(x)
x=input('Enter a Value:');
if x<-2
output=-x.^2;
elseif (-2<=x)&&(x<0)
output=-2.*x;
elseif (0<=x)&&(x<=2) output=2.*x;
elseif x>2
output=x.^2;
end
fplot(myfun(-10:10),output)
xlabel('x(m)')
ylabel('f(x)')
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!