Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: adding trendline to a plot

$
0
0
On 12/23/2012 1:15 AM, Isa Isa wrote:
> Good Day,
>
> Please how do I add trendline(s) to a certain straight line portion(s)
> of a plot and how to extend the trendline to touch y and or x axis and
> the y and or x axis value determined?

Select the data of interest any do polyfit to get coefficients and
polyval to evaluate it over the range(s) of interest. Then just set
'hold on' and add the line w/ whatever set of colors, points, linestyle,
etc., desired...

> Another related question is that how do I insert horizontal line on a
> plot and extend it to touch y axis and the y axis value determined?

doc line % to draw lines

You'll have to have some way to decide what the y-value is going to be;
Matlab can't return a value w/o knowing what value it is that you're
wanting. If the line is horizontal, the y-value is constant so what is
it that determines where the line should be? Whatever that logic is is
what you need to implement to find that value.

--

Viewing all articles
Browse latest Browse all 19628

Trending Articles