PDA

查看完整版本 : 怎样让滑动条的数值通过公式画出图形来?


yangn2003
2008-07-01, 18:44
我想要运行一个横轴为se,纵轴为sa,公式为E=se/sa 的图形来,通过滑动条让用户自己确定E的值,se,sa的值自动生成,可是图形始终出不来,下面是我的代码,在sa,se和flag的设立上总是显示有错误。

function varargout = ex72(varargin)

% Edit the above text to modify the response to help ex72
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ex72_OpeningFcn, ...
'gui_OutputFcn', @ex72_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
% End initialization code - DO NOT EDIT

% --- Executes just before ex72 is made visible.
function ex72_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);

% --- Outputs from this function are returned to the command line.
function varargout = ex72_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

% --- Executes on slider movement.
function ex72_E_Callback(hObject, eventdata, handles)


% --- Executes during object creation, after setting all properties.
function ex72_E_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end

% --- Executes on button press in ex72_plot.
function ex72_plot_Callback(hObject, eventdata, handles)
flag=get(handles.ex72_E,'Value'); %get the value of the slider
sa=flag*se; 问题所在

axes(handles.ex72_axes) %claim the graph drawed on the ex71_axes
plot(se,sa)

% --- Executes on button press in ex72_close.
function ex72_close_Callback(hObject, eventdata, handles)