MATLAB ERROR for programming

1 view (last 30 days)
UCTI
UCTI on 5 Jun 2013
Dear all,
There seems to be an error for this coding, and i am unable to find the error, can someone please help me on this?
Kindest regards,
function Gui_Testing
%MenuBar none position [x,y,lebarx,lebary]
figure('Name','Voice Recognition System','NumberTitle','off',...
'Position',[200,400,500,280]);
Title = {'VOICE RECOGNITION SYSTEM'};
uicontrol('Style','text','String',Title,'FontSize',15,...
'FontWeight','bold','ForegroundColor','b',...,
'Position',[80 150 350 100]);
Instruction = {'Command:','',...
'1. to open the motor = " MOTOR OPEN " ',...
'2. to close the motor = " MOTOR SWITCH OFF "',...
'3. to open the lights = " LIGHTS ON " ',...
'4. to close the lights = " CLOSE " '};
uicontrol('Style','text','String',Instruction,'FontSize',10,...
'FontWeight','bold','Position',[80 90 350 110]);
Check_PushButton = uicontrol('Style','PushButton','String','ENTER COMMAND',...
'Position',[100,30,110,50],'CallBack', ...
@PushButtonSelected);
% List = {'COM1','COM2','COM3','COM4'};
% PopupMenu = uicontrol('Style','PopupMenu','String',List,...
% 'Position',[140,60,100,20],'CallBack',
@PopupMenuCallBack);
%function PopupMenuCallBack(varargin)
% List = get(PopupMenu, 'String');
% Val = get(PopupMenu, 'Value');
% msgbox(List{Val}, 'Selecting:', 'modal')
end
uicontrol('Style','PushButton','String','CLOSE',...
'Position',[300,30,110,50],'CallBack','close');
function PushButtonSelected(varargin)
if get(Check_PushButton,'Value')==1 59
pot = 'COM1';
SerPIC = serial(pot);
set(SerPIC,'BaudRate',9600,'DataBits',8,'Parity','none','Stopbits',1,'FlowControl','none');
fopen(SerPIC);
Fs = 8000; % sampling frequency
n_samples = 5*Fs; % record n samples of an audio signal
play_command = wavread; %read file
wavplay(play_command,Fs) ;
y=wavrecord(n_samples,Fs); % record 5 sec
wavwrite(y,Fs,); % save file
x = wavread; % read file
%figure(1);plot(x);grid;xlabel('Hertz') % plot graph x
[b a]=size(x);
c1=0; % starting variable
c2=0; % ending variable
n1=0.15; % amplitud starting
n2=0.15; % amplitud ending
z =1; % starting for new variable
% loop to determine starting point
for n=1:b % for 1 -> 40000 where b=40000
if (x(n,1)>n1)
c1=n; % starting variable,c1=n
break;
end
end
% loop to determine ending point
for n=b:-1:1 % for 40000 -> 1 where b=4000
if (x(n,1)>n2)
c2=n; % ending variable,c2=n
break;
end
end
% loop to determine selected word signal
for n=c1:c2 % signal between c1 <-> c2
x2(z,1)=x(n+1,1);
z=z+1;
end
% create new x signal
for n=1:a
x(n,1)=0;
end60
%x=x2;
%figure(2);plot(x);grid;xlabel('Hertz') % plot graph x
motor_opened_max = 7000;
motor_opened_min = 6000;
motor_closed_max = 10500;
motor_closed_min = 7800;
lights_opened_max = 5000;
lights_opened_min = 3500;
lights_closed_max = 2200;
lights_closed_min = 800;
%determine command for each signal
if (z >= motor_opened_min && z <= motor_opened_max)
f = 'a';
end
if (z >= motor_closed_min && z <= motor_closed_max)
f = 'b';
end
if (z >= lights_opened_min && z <= lights_opened_max)
f = 'c';
end
if (z >= lights_closed_min && z <= lights_closed_max)
f = 'd';
end
%determine error
if (z > motor_closed_max || ( z > motor_opened_max && z < ...
motor_closed_min ) || ( z > lights_opened_max && z < ...
motor_opened_min ) || ( z > lights_closed_max && z < ...
lights_opened_min) || z < lights_closed_min)
f= 'e';
end
fprintf(SerPIC,'%s',f);
fclose(SerPIC)
delete(SerPIC)
clear SerPIC
end
end
end
  6 Comments
Walter Roberson
Walter Roberson on 5 Jun 2013
No problem, just use infinitesimally small bottles of beer.
Sean de Wolski
Sean de Wolski on 5 Jun 2013
That would be cheating...

Sign in to comment.

Answers (1)

John
John on 5 Jun 2013
Line 22 needs a comment (or uncomment the rest... depending on what you're trying to do)
lines 28 and 29 are not within any function
line 41 has an extra comma
line 31: what is the 59 for?
line 31: I don't think you have access to Check_PushButton, because you defined it in a separate function and it doesn't appear to be global...
That's a start...

Categories

Find more on Specialized Power Systems in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!