grapg is not activate plz help me
1 次查看(过去 30 天)
显示 更早的评论
function mornig
global A F T;
N=500;
M=300;
handles.fig=figure;
mpos=get(handles.fig,'position');
set(handles.fig,'position',[mpos(3) mpos(4) N M]);
handles.axes=axes();
set(handles.fig,'unit','pixels');
set(handles.axes,'unit','pixels');
handles.edit1=uicontrol('style','edit');
set(handles.edit1,'position',[N-360 0 120 20]);
set(handles.edit1,'string','A');
set(handles.edit1,'horizontalalignment','center');
handles.edit2=uicontrol('style','edit');
set(handles.edit2,'position',[N-240 0 120 20]);
set(handles.edit2,'string','F');
set(handles.edit2,'horizontalalignment','center');
handles.edit3=uicontrol('style','edit');
set(handles.edit3,'position',[N-120 0 120 20]);
set(handles.edit3,'string','T');
set(handles.edit3,'horizontalalignment','center');
set(handles.edit1, 'callback', {@edit_callback1, handles,A});
set(handles.edit2, 'callback', {@edit_callback2, handles,F});
set(handles.edit3, 'callback', {@edit_callback3, handles,T,A,F});
function edit_callback1(gcf, event_data, handles, A)
handles.text1=get(handles.edit1,'string');
A=(handles.text1);
function edit_callback2(gcf, event_data, handles, F)
handles.text2=get(handles.edit2,'string');
F=(handles.text2);
function edit_callback3(gcf, event_data, handles, T, A, F)
handles.text3=get(handles.edit3,'string');
T=(handles.text3);
plot(handles.axes,T,A*cos(2*pi*F*T));
write amplitud , freuency, time
and drawing but activate do not..
help me
0 个评论
采纳的回答
Walter Roberson
2015-12-3
function mornig
A = 0; F = 0; T = 0; %not global!
N=500;
M=300;
handles.fig=figure;
mpos = get(handles.fig,'position');
set(handles.fig, 'position',[mpos(3) mpos(4) N M]);
handles.axes = axes();
set(handles.fig,'unit','pixels');
set(handles.axes,'unit','pixels');
handles.edit1 = uicontrol('style','edit');
set(handles.edit1,'position',[N-360 0 120 20]);
set(handles.edit1,'string','A');
set(handles.edit1,'horizontalalignment','center');
handles.edit2 = uicontrol('style','edit');
set(handles.edit2,'position',[N-240 0 120 20]);
set(handles.edit2,'string','F');
set(handles.edit2,'horizontalalignment','center');
handles.edit3 = uicontrol('style','edit');
set(handles.edit3,'position',[N-120 0 120 20]);
set(handles.edit3,'string','T');
set(handles.edit3,'horizontalalignment','center');
set(handles.edit1, 'callback', @edit_callback1);
set(handles.edit2, 'callback', @edit_callback2);
set(handles.edit3, 'callback', @edit_callback3);
%now nested functions
function edit_callback1(src, event_data)
A = str2double( get(src, 'String') );
end
function edit_callback2(src, event_data)
F = str2double( get(src, 'String') );
end
function edit_callback3(src, event_data)
T = str2num( get(src, 'String') ); %because it probably is not a scalar
plot(handles.axes, T, A*cos(2*pi*F*T));
end
Note that in order for you to see much, you will need to enter a vector of values for T
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!