There is no String property on the Figure class? GUI issue.
2 views (last 30 days)
Show older comments
Michael Stewart
on 2 May 2017
Commented: Michael Stewart
on 3 May 2017
I have been trying to get this code to work, but I keep getting the same error.
Error using matlab.ui.Figure/set
There is no String property on the Figure
class.
Error in SpdRdr>pushbutton2_Callback (line
172)
set(handles.output1,'String',myInput{i});
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in SpdRdr (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)SpdRdr('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
The issue is with this line of code:
set(handles.output1,'String',myInput{i});
text = get(handles.stringinput,'String');
myInput = strsplit(text)
prompt = get(handles.rateinput,'String');
rate = str2num(prompt);
for i = 1:length(myInput
set(handles.output1,'String',myInput{i});
pause(60/rate);
end
4 Comments
dpb
on 2 May 2017
If it once was, it is no longer at the time you're trying to use it above, no. As the error message says, that variable now is pointing at a figure; Matlab doesn't lie on error messages.
As S Lord says, set a breakpoint in the function and step through to see when this changes...look for an inadvertent assignment in your code shouldn't have made, maybe.
Accepted Answer
Honglei Chen
on 2 May 2017
From the error message, it seems that the handles.output1 variable points to a figure class, which does not have a string property. So you need to point that to the textbox you want.
HTH
3 Comments
Steven Lord
on 2 May 2017
According to the error message handles.output1 is NOT the handle of a static text box. If it was originally, it is not now. Something must have overwritten it. To check this, you can set a breakpoint on the line where you try to perform that set call and check to what type of graphics object handles.output1 refers.
If as we suspect it is a figure object, check your code for wherever you assign a value to handles.output1 and make sure that you're performing the assignment you think you are.
More Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!