grapg is not activate plz help me

4 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 3 Dec 2015
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
  5 Comments
rollcakes
rollcakes on 4 Dec 2015
function hh
N=800;
M=600;
A = 0; F = 0; S = 0; Fi=0;
Fs=100;
Ts=1/Fs;
t=[-6:Ts:6];
handles.fig=figure();
mpos=get(handles.fig,'position');
set(handles.fig,'units','pixel');
set(handles.fig,'position',[mpos(3)-120 mpos(4)-250 N M]);
handles.axes1=axes();
set(handles.axes1,'units','pixel');
handles.axes1=subplot(3,1,1);
handles.axes2=axes();
set(handles.axes2,'units','pixel');
handles.axes2=subplot(3,1,2);
handles.axes3=axes();
set(handles.axes3,'units','pixel');
handles.axes3=subplot(3,1,3);
handles.filter1=uicontrol('style','radiobutton');
set(handles.filter1,'string','low pass');
set(handles.filter1,'position',[100 200 80 20]);
handles.filter2=uicontrol('style','radiobutton');
set(handles.filter2,'string','highpass');
set(handles.filter2,'position',[100 180 80 20]);
handles.filter3=uicontrol('style','radiobutton');
set(handles.filter3,'string','band pass');
set(handles.filter3,'position',[100 160 80 20]);
handles.edit1=uicontrol('style','edit');
set(handles.edit1,'position',[N-360 0 120 20]);
set(handles.edit1,'string','A');
set(handles.edit1,'horizontalalignment','center');
set(handles.filter1,'callback',{@mycallback, handles, 1});
set(handles.filter2,'callback',{@mycallback, handles, 2});
set(handles.filter3,'callback',{@mycallback, handles, 3});
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');
set(handles.edit1, 'callback', @edit_callback1);
set(handles.edit2, 'callback', @edit_callback2);
function edit_callback1(src, event_data)
A = str2double( get(src, 'String') );
end
function edit_callback2(src, event_data)
F = str2double( get(src, 'String') );
S=A*cos(2*pi*F*t);
plot(handles.axes1, t, S);
end
function mycallback(gcf, event_data, handles, filter_num)
switch filter_num
case 1
set(handles.filter1,'value',1);
set(handles.filter2,'value',0);
set(handles.filter3,'value',0);
Fi=rectpuls(t/4);
plot(handles.axes2,t,Fi);
axis(handles.axes2, [-6 6 0.01 2]);
xlabel(handles.axes2,'frequency(hz)');
ylabel(handles.axes2,'Filter');
title(handles.axes2,'Low Pass Filter impulse');
plot(handles.axes3, t, (Fi*S));
case 2
set(handles.filter1,'value',0);
set(handles.filter2,'value',1);
set(handles.filter3,'value',0);
Fi=1*(t>3)+1*(t<(-3));
plot(handles.axes2,t,Fi);
axis(handles.axes2, [-6 6 0.01 2]);
xlabel(handles.axes2,'frequency(hz)');
ylabel(handles.axes2,'Filter');
title(handles.axes2,'High Pass Filter impulse');
plot(handles.axes3, t,(Fi*S));
case 3
set(handles.filter1,'value',0);
set(handles.filter2,'value',0);
set(handles.filter3,'value',1);
Fi=1*(t>2&t<4)+1*(t<(-2)&t>-4);
plot(handles.axes2,t,Fi);
axis(handles.axes2, [-6 6 0.01 2]);
xlabel(handles.axes2, 'frequency(hz)');
ylabel(handles.axes2,'Filter');
title(handles.axes2, 'Band Pass Filter frequency');
plot(handles.axes3, t, (Fi*S));
end
end
end
please one thing
why not work
plot(handles.axes3, t, (Fi*S));

Sign in to comment.

More Answers (0)

Categories

Find more on Stress and Strain in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!