Any help on this would be much aprpeciated as it is the final part I am stuck on for a project, and have next to no help as teaching is 100% online. Thanks!
Dot indexing is not supported for variables of this type when trying to write value into static text box
2 次查看(过去 30 天)
显示 更早的评论
function text7_CreateFcn(hObject, eventdata, handles)
value=1;
set(handles.text7, 'String', num2str(value))
I am trying to add a value that will be determined by a slider in my GUI into the text of a static text box, but recieve the error message 'Dot indexing is not supported for variables of this type'
3 个评论
采纳的回答
Image Analyst
2020-10-17
Do not put anything into the CreateFcn() functions of controls. If you want something to be initialized with a value, then put that value into the String property of the control in GUIDE, not in the CreateFcn.
Now, to get the value of a slider and put it in the text box as you move the slider, you'd put it into the callback function of the slider, not the callback of the text box.
function slider1_CallbackFcn(hObject, eventdata, handles)
value = handles.slider1.Value;
textLabel = sprintf('Slider = %.3f', value);
% Update text box
handles.text7.String = textLabel;
0 个评论
更多回答(2 个)
Fangjun Jiang
2020-10-16
编辑:Fangjun Jiang
2020-10-16
set(hObject, 'String', num2str(value))
see this comment ?
% hObject handle to edit1 (see GCBO)
% handles empty - handles not created until after all CreateFcns called
4 个评论
Rik
2020-10-17
No, set(hObject,'String',num2str(value)).
Using a programmatic GUI (and not AppDesigner) offers a wide variety of benefits. I would encourage you to check out the thread I linked in my previous comment.
Walter Roberson
2020-10-17
function text7_CreateFcn(hObject, eventdata, handles)
value = 1;
set(hObject, 'String', num2str(value))
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!