Error with set(handle​s.text1,'S​tring','te​st') at GUI

Hello,
I'm working on some GUIs and I use the set(handles.anything,...) command often. Today when I opened Matlab and tried to work on the project, I get errors evertime, a line occurs, using the syntax 'handles.anything'. The notion is: "Attempt to reference field of non-structure array." The error is not limited to a certain command. I reduced the problem to a blank gui, inserting a text field and a button. By clicking the button, one command works fine (this uses 'gcf'), the other one fails:
set(handles.text1,'String','anything');
Thank you for your help.
Ferdinand

6 件のコメント

Friedrich
Friedrich 2012 年 4 月 18 日
Can you post the gui code from your example?
Ferdinand Trommsdorff
Ferdinand Trommsdorff 2012 年 4 月 18 日
編集済み: Walter Roberson 2018 年 12 月 7 日
Of course, but this is mainly the automatically generated GUI by Guide. I deleted all out commented lines.
The only change is done at "function pushbutton1_Callback".
function varargout = test_gui(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @test_gui_OpeningFcn, ...
'gui_OutputFcn', @test_gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function test_gui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = test_gui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
display Goodbye
f=get(gcf,'Position');
set(gcf,'Position',[f(1)*rand f(2)*rand f(3) f(4)]);
set(handles.text1,'String','CHANGED TEXT');
Jakob Sørensen
Jakob Sørensen 2012 年 4 月 18 日
Have you written it inside the initialization code?
Because if you look at the comment in the beginning of that section, that could be the problem.
Ferdinand Trommsdorff
Ferdinand Trommsdorff 2012 年 4 月 18 日
I didn't wrote it into the initialization. The format here is not very clear.
In the meantime, I recognized the following: if I run the m-file, the GUI works. If I run the figure, which belongs to the GUI, the error is produced.
I think, this is it. Just run the name of the file and not the figure itself.
Mohamed Samir
Mohamed Samir 2018 年 12 月 7 日
Error in ==> ImageCompression1>pushbutton1_Callback at 91
set(handles.text7,'string',Size);
Walter Roberson
Walter Roberson 2018 年 12 月 7 日
There would have been more to the error message than that?

サインインしてコメントする。

回答 (1 件)

Carlos Andres Ramiez Irene
Carlos Andres Ramiez Irene 2017 年 11 月 25 日
編集済み: Walter Roberson 2017 年 11 月 25 日

0 投票

% ---Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved -to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x;
ingreso=char(inputdlg('ingrese funcion'));
f=inline(ingreso);
n=str2double(inputdlg('ingrese numero de expresiones para la serie'));
ev=taylor(f(x),'order',n)
fun=string(ev);
set(handles.text1,'string',fun);
% me sale este error Not enough input arguments.
%Error in pushbutton1_Callback (line 12)
%set(handles.text1,'string',fun);

カテゴリ

ヘルプ センター および File ExchangeTime Series Objects についてさらに検索

タグ

質問済み:

2012 年 4 月 18 日

コメント済み:

2018 年 12 月 7 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by