MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] 急、跪求、紧急求助 (https://www.labfans.com/bbs/showthread.php?t=12238)

hontrcoogle 2010-11-08 15:04

急、跪求、紧急求助
 
初学者求助啊:如何从edittext中获取参数 x5,然后计算y = x1*x5;:)
-----------------代码----------------------------
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)

handles.output = hObject;

guidata(hObject, handles);


function varargout = untitled_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;



function lc201010_Callback(hObject, eventdata, handles)
x1 = 0;
x5 = str2double(get(handles.lc201010,'string'));

function lc201010_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function pushbutton1_Callback(hObject, eventdata, handles)
y = x1*x5;
fprintf('%d',y);
-----------------------错误信息---------------------------
??? Undefined function or variable 'x1'.

Error in ==> untitled>pushbutton1_Callback at 43
y = x1*x5;

Error in ==> gui_mainfcn at 96
feval(varargin{:});

Error in ==> untitled at 16
gui_mainfcn(gui_State, varargin{:});

Error in ==>
@(hObject,eventdata)untitled('pushbutton1_Callback',hObject,eventdata,guidata(hObject))


??? Error while evaluating uicontrol Callback


所有时间均为北京时间。现在的时间是 14:03

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.