calculating and displaying the slope of a line
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I create a figure with toggle button on its toolbar by uitoggletool. The callback function for it is shown below:
function calc_slope(handle,event)
on = get(handle,'State');
if strcmpi(on,'on') || strcmpi(on,'off'),
xy=imline;
addNewPositionCallback(xy,@(xy)...
title(['\DeltaY/\DeltaX = ',num2str((xy(4)-xy(3))/(xy(2)-xy(1))),...
'[\DeltaX = ',num2str(xy(2)-xy(1)),...
',\DeltaY = ',num2str((xy(4)-xy(3))),']']));
end
As you can see, the example outputs the position data in the title of a figure using the 'title' command.
Is there a way to output this in a text box using the 'text' command?
I want to display the slope next to the line drawn.
Also, it will be great if the text box also gets deleted together with the associated line.
Please, help.
Thank you,
Eric
0 Commenti
Risposte (2)
Purushottama Rao
il 3 Set 2015
Modificato: Stephen23
il 8 Set 2015
You can try uicontrol. Change the position coordinates according to your requirement. The same thing can be expanded for delta x and delta y as well.
uicontrol('Style','text','String',num2str(num2str((xy(4)-xy(3))/(xy(2)-xy(1)))),'Position',[120 350 300 25],'Fontsize',18);
Image Analyst
il 3 Set 2015
Use sprintf() to create your string, then use text() to place it wherever you want.
2 Commenti
Image Analyst
il 7 Set 2015
"It deletes all other text boxes" <-- then why do you call delete at all?
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!