Azzera filtri
Azzera filtri

Global Function not always working?

1 visualizzazione (ultimi 30 giorni)
Trevor Zane Simko
Trevor Zane Simko il 8 Mag 2015
Let me start this off saying that I'm not very familair with MATLAB. I'm a first year engineering student working on a final project and I might have decided to try a project a tad out of my lead. So please specific with your advice. With that said, here's my problem:
I have a total of 5 figures (GUI's) with pushbuttons. Under the pushbuttons function I have written:
global Variable_One
Variable_One={1 'Name'};
close
Then, in my script, I assign Variable_One to my workspace by using:
openfig('Figure1','reuse');
uiwait(Figure1)
global Variable_One;
With my first two figures, this works perfectly. However when trying to do the same with the third figure later on in the script, Variable_Three is assigned to [] rather than {3 'Name'} .
So frustrating! I'm so close to finishing this project. Plese, all help appreciated thank you.

Risposte (1)

Walter Roberson
Walter Roberson il 8 Mag 2015
That would happen if your routine that defines Variable_Three is missing the
global Variable_Three
before the assignment.
Double-check that the global is present and that you have used the same variable name there -- for example that you do not accidentally have
global Variable_three
or
global Variable_Trhee
  2 Commenti
Trevor Zane Simko
Trevor Zane Simko il 8 Mag 2015
I triple checked everything. Every capital letter, underscore, etc. is in check. The code is identical to the working code earlier in the script (except for the variable names of course) That's why I'm so confused.
Walter Roberson
Walter Roberson il 8 Mag 2015
Could you add a disp() or a breakpoint to be sure the assignment is being reached? In case for example a different callback is being invoked than what you expect

Accedi per commentare.

Categorie

Scopri di più su Interactive Control and Callbacks 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!

Translated by