problem with ginput and figure userdata

1 visualización (últimos 30 días)
Steve Grobler
Steve Grobler el 29 de Mzo. de 2016
Comentada: Stephen23 el 25 de Jul. de 2016
In v2014b my m-file using ginput(2) worked fine. In v2015b it fails. It looks like ginput was re-written for 2015b? So I have a figure open and I have stored some data in its UserData like this:
Info.LF=LF;
Info.LMA=LMA;
Info.SPD=SPD;
Info.S = S;
Info.T = T;
Info.Mode = Mode;
Info.fname = fname;
Info.SF = SF;
set(gcf,'UserData',Info)%,'HandleVisibility','callback')
Now when I call [x,~]=ginput(2) to pick a coule of points on the graph, ginput crashes on the line 84 (switch mode) with this error message: "SWITCH expression must be a scalar or string constant. Error in ginput (line 84) switch mode"
if (isCorrectFigure(fig))
switch mode
case 'key'
char = get(fig, 'CurrentCharacter');
curUserInput = abs(get(fig, 'CurrentCharacter')); ...etc
Somehow the variable mode in ginput has been filled with my figure UserData, which I gather has happened in line 69 of ginput ie:
mode = waitForUserInput(fig);
Can anyone explain why ginput is now messing with the figure's UserData and how I might resolve this? Many thanks Steve

Respuestas (1)

Jeevan Joishi
Jeevan Joishi el 4 de Abr. de 2016
I understand that you have a figure and you have some user defined data in it. And when you try running ginput on the current figure, an error is thrown in R2015b but it did not happen in R2014b.
I tried reproducing this issue with a sample GUI that sets some data and then call ginput on a click of a button. For both R2014b and R2015b, there were no reported errors and the GUI behaved as expected.
Please have a look at the attached GUI and M-Script and leave a comment if the error is reproducible with the sample or if you can modify the sample to reproduce the error.
  1 comentario
Steve Grobler
Steve Grobler el 11 de Mayo de 2016
thanks for your reply, I've not been able to get back to this until now. I did something similar to what you had done and was unable to replicate the problem. However I've now cut down my original code to reproduce the problem : Run the attached test_gui.m and then choose the "Select test" button on the menu bar - this will load a .mat file with some variables. Then press the "test_ginput" button and try to pick somewhere in any of the axes...

Iniciar sesión para comentar.

Categorías

Más información sobre Data Exploration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by