Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Basic Matlab question

  1. Oct 2, 2006 #1
    Hey guys. Can someone help me with the syntax needed to label the root of a function on a graph, using Matlab? I've used the help function, but I couldn't find anything that was effective. Thanks.
  2. jcsd
  3. Oct 4, 2006 #2
    I'm not sure if there's a way to make Matlab find and label roots on a plot, but you can make it find them separately and plot that point on the plot.

    For example, if you are plotting y vs. t and want to find the roots of y, you can do
    roots = find(abs(y)<=eps)
    (or roots = find(abs(y) == min(abs(y))) if you know there's only one root). This finds the indices in the y vector corresponding to (approximately) the roots of y.

    Then you can do
    to plot y vs. t, and then on top of that it plots stars on the points where you found roots. There may be better ways but that's the best thing I can think of off hand.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Basic Matlab question
  1. Matlab basics (Replies: 2)

  2. Basic MATLAB (Replies: 10)

  3. Matlab - basic script (Replies: 1)