Create a function called g that satisfies the following crit
Create a function called g that satisfies the following criteria: For x pi, g(x) = -1 Plot your results for values of x from -2 pi TO +2 pi. Choose your spacing to create a smooth curve.
Solution
As far as the the layout of the function and calling from another program is concerned, you have to create the function by going to MATLAB. The following steps might help.
1.File ---> New----> Function
2.Paste the code after deleting everything that was present earlier.
3.Save it at the same folder as your calling program.
4.To use this g function from the main program, just type y=g(x) e.g. g(pi) at your main program function whenever you need to compute g(x).
And the function with the switch /case commands is
Hope this helps!
