One of the problems I've always had with Matlab was that I could never seem to get it to easily do what, in my mind, was the simplest little thing: graph a function. Since the availability of Wolfram|Alpha, also known as the single most useful computational tool on the internet, I've been going there to basically have Mathematica do my plotting for me whenever I need a quick glance at a function. (I've been informed there's also a site called FooPlot that can do some easy graphing, but haven't really tried it myself.)
Finally, however, I've managed to get Matlab to cooperate. In hindsight, my problem was probably being too lazy/impatient to take advantage of what most people agree is an exceptional help menu, but there were a couple of things I didn't know that made the difference for me. Here goes:
- There's something called a "function handle" that can be used in a .m file (or just at the command line, if you like) to identify a function you want to plot. An example might be f(x)=e^(-x^2). You can create a function handle by typing "function=@(x) e^(-x^2)" where "function" is the name of the thing, "@" creates your handle and says that this thing ("x") is variable, and whatever equation you want goes after.
- This is followed by the command "fplot". The full command would be something like "fplot(function, [0, 3])" with "function" being whatever name you called it and the bracketed values indicating the interval over which your function is plotted. In this example, the function would plot between "zero" and "three".
1 comments:
Why not just use Mathematica?
Post a Comment