具体代码如下:
function varargout = untitled (varargin )
gui_Singleton = 1;
gui_State = struct (‘gui_Name’ ,
mfilename , …,
‘gui_ Singleton ’,
gui_ Singleton, …
‘gui_ OpeningFcn’, @untitled_ OpeningFcn, …
‘gui_ OutputFcn’,
@untitled_ 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 untitled_ OpeningFcn (hObject, eventdata, handles, varargin)
[fname,pname] = uigetfile (‘*.amp’ , ‘sample Dialog Box’);
handles.output = hObject;
guidata( hObject,handles);
function varargout = untitled_ OutputFcn ( hObject, eventdata, handles )
varargout {1} =handles.output;
function A_Callback
( hObject, eventdata, handles )
A_state=get(hObject, ‘ Value ’);
if A_state = = get(hObject, ‘ Max ’)
A = str2double (get(handles.A, ‘String’));
end
function B_Callback
( hObject, eventdata, handles )
B_state=get(hObject, ‘ Value ’);
if B_state = = get(hObject, ‘ Max ’)
B = str2double (get(handles.B, ‘String’));
end
function C_Callback
( hObject, eventdata, handles )
C_state=get(hObject, ‘ Value ’);
if C_state = = get(hObject, ‘ Max ’)
C = str2double (get(handles.C, ‘String’));
end
function D_Callback ( hObject, eventdata, handles )
D_state=get(hObject, ‘ Value ’);
if D_state = = get(hObject, ‘ Max ’)
D = str2double (get(handles.D, ‘String’));
end
function E_Callback ( hObject, eventdata, handles )
E_state=get(hObject, ‘ Value ’);
if E_state = = get(hObject, ‘ Max ’)
E = str2double (get(handles.E, ‘String’));
end
function F_Callback ( hObject, eventdata, handles )
F_state=get(hObject, ‘ Value ’);
if F_state = = get(hObject, ‘ Max ’)
F = str2double (get(handles.F, ‘String’));
end
function edit_Callback ( hObject, eventdata, handles )
function edit_CreateFcn ( hObject, eventdata, handles )
if ispc && isequal (get(hObject, ‘ BackgroundColor ’), get
(0, ‘ defaultUicontrolBackgroundColor ’))
set (hObject, ‘ BackgroundColor ’, ‘white’ );
end
function read_Callback ( hObject, eventdata, handles )
read_state=get(hObject, ‘ Value ’);
if read_state = = get(hObject, ‘ Max ’)
fidaus=fopen(’18.amp’,’w’)
fprintf(fidaus,’%f
%f
%f
%f
%f
%f\n’.A, B, C, D, E, F)
end
我现在用了uigetfile来引入文件,这样会弹出一个对话框,但我的本意是想用edittext来输入文件路径的,而不想弹出对话框,具体界面在附件里.但我不知道
function edit_Callback ( hObject, eventdata, handles )
function edit_CreateFcn ( hObject, eventdata, handles )
这2个函数应该怎么编,即我怎样通过edittext中的文件路径来读入文件的内容,还请高手指教.
还有我现在的程序运行以后会出现以下的错误:
fidaus=
1
??? Undefined function or variable 'A'.
Error in ==>read_Callback
fprintf(fidaus,’%f
%f
%f
%f
%f
%f\n’.A, B, C, D, E, F)
Error in ==>gui_mainfcn
feval(varargin{:});
Error in ==>
gui_mainfcn(gui_State,varargin{:});
??? Error while evaluating uicontrol Callback
实在是不知道该怎么办了,还请高手帮忙,另外界面在附件里.
万分感谢!
|