problem with ginput and figure userdata
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
Risposte (1)
Jeevan Joishi
il 4 Apr 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.
Vedere anche
Categorie
Scopri di più su Data Exploration 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!