You can plot x vs y over the same domain using the fplot
function in Matlab. Here's an example:
main.m191 chars14 lines
In this example, we define a function f
(in this case, the sine function) and an array x
that represents the domain over which we want to plot. We then use the fplot
function to plot f
over the values in x
. Finally, we add labels to the x and y axes and a title to the plot.
Note that fplot
requires a function handle as the first input argument. If your function is defined in a separate file, you can create a function handle by using the @
symbol followed by the function name. For example, if your function is defined in a file called myFunction.m
, you would use fplot(@myFunction, x)
.
Hope this helps!
gistlibby LogSnag