문제

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?

도움이 되었습니까?

해결책

Change

pos = sprintf('edit%', i)

to

pos = sprintf('edit%d', i)

That specifies i should be formatted as an integer when building the string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top