How to iterate over edit text fields in matlab GUI?
-
21-12-2019 - |
Domanda
In my GUI I have quite some edit fields with the names edit1, edit2, ..., editn. I try to access them in a loop.
I tried following:
for i=1:n
pos = sprintf('edit%', i);
content = get(handles.(pos), 'String');
with the following error message:
Reference to non-existent field 'pos'
Ideas? Anyone?
Soluzione
Change
pos = sprintf('edit%', i)
to
pos = sprintf('edit%d', i)
That specifies i
should be formatted as an integer when building the string.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow