How to write the Text in Text Box using For Loop
显示 更早的评论
I want to display the Channels # as from 1 to 32 at the Start up using for loop.
handles.text_ch = [];
for range = 1:32
set(handles.text_ch,'String',range);
end
But this command didn't work. Please guide me.
回答(1 个)
Jan
2018-11-30
Of course the shown code cannot work. By the way, prefer to pos the error message instead of the general statement "didn't work".
handles.text_ch = []; % Now handles.text_ch is teh empty matrix
for range = 1:32
% You cannot set the 'String' property of an empty matrix:
set(handles.text_ch, 'String', range);
end
You need to use the correct handles. I cannot guess, what the text_ch field of the handles struct is. If it is a vector of handles of text objects, use:
Offset = 0;
for range = 1:32
set(handles.text_ch(range), 'String', sprintf('%d', range + Offset * 32));
end
Now set the Offset to the index of the radio button.
Maybe handles.text_ch is something else. Then please mention, how it was created.
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!