File Exchange

image thumbnail

getslopeintercept

version 1.3.0.0 (2.22 KB) by Jean-Luc Dellis
In the current figure, you have to click twice. The function will display the slope and the intercept of the drawn line in a text box.

1 Download

Updated 13 Nov 2018

View Version History

View License

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 click twice.
The GETSLOPEINTERCEPT function will display
the slope and the intercept of the drawn line in a text box
EXAMPLE
plot([1:10],[1:10].^0.5,'-o')
getslopeintercept

Cite As

Jean-Luc Dellis (2021). getslopeintercept (https://www.mathworks.com/matlabcentral/fileexchange/23415-getslopeintercept), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

Jean-Luc Dellis

Merci Chibuzo, I just have update the code in simplifiing it and to comply the last Matlab releases.

Chibuzo Chukwu

I tried running the code with the current MATLAB version and it showed these error lines

Error using getslopeintercept (line 46)
Error while evaluating Figure WindowButtonMotionFcn.

Can someone help me out!

Benjamin

This was useful to me.Thank you

Jean-Luc Dellis

Hi juan,
Sorry but the code processes matlab figures, not images... The easy way to handle your goal would be to use the program "GRABIT" (author:Jiro Doke). Using this great program, you would be able to produce figures from your images and then, to use "GETSLOPEINTERCEPT". Cheers.

juan ignacio gossn

High Jean!

I wish your function could be applied to gray scale images... since I'm interested in measuring slopes on such images.

When I try to use getslopeitersect I get: ??? Error using ==>
getslopeintercept at 23
There is No Curve !!

Is there an easy solution to this problem?? Thanks, a lot

greetings from argentina

Jay

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

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

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.

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!