MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   怎样让滑动条的数值通过公式画出图形来? (https://www.labfans.com/bbs/showthread.php?t=3779)

yangn2003 2008-07-01 18:44

怎样让滑动条的数值通过公式画出图形来?
 
2 个附件
我想要运行一个横轴为se,纵轴为sa,公式为E=se/sa 的图形来,通过滑动条让用户自己确定E的值,se,sa的值自动生成,可是图形始终出不来,下面是我的代码,在sa,se和flag的设立上总是显示有错误。

function varargout = ex72(varargin)

[COLOR="DarkGreen"]% Edit the above text to modify the response to help ex72[/COLOR]
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
[COLOR="darkgreen"]% End initialization code - DO NOT EDIT[/COLOR]

[COLOR="darkgreen"]% --- Executes just before ex72 is made visible.[/COLOR]
function ex72_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);

[COLOR="darkgreen"]% --- Outputs from this function are returned to the command line.[/COLOR]
function varargout = ex72_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

[COLOR="darkgreen"]% --- Executes on slider movement.[/COLOR]
function ex72_E_Callback(hObject, eventdata, handles)


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

[COLOR="darkgreen"]% --- Executes on button press in ex72_plot.[/COLOR]
function ex72_plot_Callback(hObject, eventdata, handles)
flag=get(handles.ex72_E,'Value'); [COLOR="DarkGreen"]%get the value of the slider[/COLOR]
[COLOR="Red"]sa=flag*se;[/COLOR] [COLOR="red"]问题所在[/COLOR]

axes(handles.ex72_axes) [COLOR="darkgreen"]%claim the graph drawed on the ex71_axes[/COLOR]
plot(se,sa)

[COLOR="darkgreen"]% --- Executes on button press in ex72_close.[/COLOR]
function ex72_close_Callback(hObject, eventdata, handles)


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

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