1.0

1.0 | 1 rating Rate this file 9 Downloads (last 30 days) File Size: 2.75 KB File ID: #23415

Get the Slope and Intercept of drawn Lines

by Jean-Luc Dellis

 

24 Mar 2009 (Updated 26 Mar 2009)

You have to draw a line in a graph to obtain the slope of a curve or of its tangent.

| Watch this File

File Information
Description

 SYNTAX:
       [p1,p2,slope,inter]=getslopeintercept
 OUTPUTS:
       P1= coordinates of the first cliked point
       P2= coordinates of the second cliked point
       SLOPE= slope of the drawn line
       INTER= intercept Y(X=0)
 WHAT ?
       In the current figure, you have to draw a line between 2
       clicked points of a planar graph. The GETSLOPEINTERCEPT
       function then displays the slope and the intercept of the
       drawn line in a text box
 EXAMPLE
       plot([1:10],[1:10].^0.5,'-o')
       getslopeintercept

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
25 Mar 2009 Matt Fig

This really needs some improvement. Since there is no help of any value, I had to read a bit of the code to figure out what I was supposed to do.

>> plot(1:10)
>> getslopeintercept
??? Cell contents reference from a non-cell array object.
Error in ==> getslopeintercept at 21

Fix the code and have a look at the help for the Matlab function 'max' as an example of how to write the help for your function.

27 Mar 2009 Jean-Luc Dellis

Thank you Matt. You were right and i have corrected the bug. It went from the kind of the output of the command
GET(findobj('type','line'),'Zdata')
which is SCALAR when only one line exists, and which is a CELL when several lines are available.
Now, GETSLOPEINTERCEPT can work with several lines and figures as well with only one. As we say in french "on a pas des métiers faciles" indeed when i worked on this function i had allways several open figure and didnt notice the variability of the output of the command. I apologize again.
Cheers,
JLD

27 Mar 2009 Jean-Luc Dellis

Oops, i sent (26 march) the updated code... It is not still published. Please before downloading it, wait it appears corrected. You also can find it in the bottom of this page:
http://www.u-picardie.fr/~dellis/
Cheers,
JLD

29 Jul 2011 Jay  
Please login to add a comment or rating.
Updates
26 Mar 2009

* fix the bug
* add an example in the help
* improve the capabilities, the function can now work on several plots
I apologize to all who downloaded the bad-coded function and thanks MATT who warms me.

Tag Activity for this File
Tag Applied By Date/Time
data exploration Jean-Luc Dellis 24 Mar 2009 14:02:41
measurement Jean-Luc Dellis 24 Mar 2009 14:02:41
trendline Travis 08 Sep 2009 17:36:06
intercept Jean-Luc Dellis 26 Mar 2010 11:38:53
curve Jean-Luc Dellis 26 Mar 2010 11:38:53
slope Jean-Luc Dellis 26 Mar 2010 11:38:53
slope vinay 16 Mar 2012 03:24:34

Contact us at files@mathworks.com