write a matlab script that allowss the user to plot one to plot one of the following functions over the range 0 less than or equal to x equal to or less than 10. x<=x<=10
Using the input command, your script should ask the user to select which function to plot. Then , the script should generate the desired plot.
I'm not really sure what i'm supposed to do for this problem, the things covered in the book seem a bit vague to me.
No products are associated with this question.
was the input 1? If so then plot cos(x). Wss the input 2? If so then plot sin(x). And so on.
I would use the menu function:
button = menu('Select one',... 'f1(x)=cos(x)',... 'f2(x)=sin(x)',... 'f3(x)=(-x^2)+10x') if button == 1 % Plot function 1 elseif button == 2 % Plot function 2 else % Plot function 3 end
But if it requires the input() function, there are examples in the help for that, which you should easily be able to adapt.
hi, try his basic sol :
fprintf(' SELECT A FUNCTION TO PLOT :\n case1 : cos(x) \n case(2) sin(x) .\n case (3) : -x^2+10x :\n'); a=input('');
figure, plot(x,sin(x)); elseif a==3
figure, plot(x,-x.^2+10*x); end
Play games and win prizes!Learn more