How do I get matlab to save different datasets depending on the key i press?

Hi,
I have a number of different x,y lines using different detection methods on an image.I want Matlab to save a specific line depending on the key I press. So if I press 1 for example, Matlab saves detection method a, if I press 2 Matlab saves detection b. I have investigated KeyPressFcn, but this doesn't work. Are there any simple functions I can use that can allow me to do this?
Many thanks in advance, John

4 Kommentare

What do you mean by 'doesn't work'? This is what KeyPressFcn is for so I imagine it works if you use it correctly.
I can't seem to get any help for the function (I am using Matlab 2016b)and no documentation exists (to my knowledge on the Mathworks pages).
doc KeyPressFcn
should take you straight to the documentation of this property for a figure.
What exactly are "different x,y lines"? What does "saving a line" mean? What is "detection method a"?
Of course the KeyPressFcn is the solution. So please post your code. You can find many examples if you ask an internet search engine for "Matlab KeyPressFcn". "No documentation exists" is simply wrong.
Please post the current code and explain explicitly, what "doesn't work" means. Do you get an error message?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sri Harish G
Sri Harish G am 10 Jul. 2018
You can refer to the following documentation : https://www.mathworks.com/help/matlab/ref/matlab.ui.figure-properties.html
Please scroll down to Keyboard Callbacks
For another function you can also refer to: https://www.mathworks.com/help/matlab/ref/waitforbuttonpress.html?searchHighlight=waitforbuttonpress&s_tid=doc_srchtitle
and do the required action based on the value of the key pressed.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 10 Jul. 2018

Kommentiert:

Jan
am 10 Jul. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by