how can i change the error in line 80 column 18?

2 次查看(过去 30 天)
function varargout = utama (varargin)
% --- Executes on button press in browse_btn.
function browse_btn_Callback (hObject, eventdata, handles)
clc
%read the file
[filename, pathname]=uigetfile ('*.wav*');
if ~isequal (filename, 0)
[y,Fs] = audioread(fullfile (pathname,filename));
a=0.97;
y2= filter ([1-a], 1, y);
time=(1:length(y))/Fs;
time1=(length(y))/Fs;
axes (handles.axe_original);
plot(time, y);
grid on
set (gca, 'unit', 'pixel');
set (handles.editbrowse, 'string',filename)
set (handles.editsamplerate,'string',Fs);
set (handles.editsampletime,'string',time1);
[y,Fs] = audioread(fullfile(pathname,filename));
else
return
end
handles.y2 = y2;
handles.y = y;
handles.Fs = Fs;
handles.timel = timel;
guidata(hObject,handles)
%---Executes on button press in Mel-Frequency Ceptral Coefficient_btn.
function Mel_Frequency_Ceptstral_Coefficient_btn_Callback(hObject, eventdata, handles)
%hObject handle to Mel-Frequency Cepstral Coefficient_btn (see GCBO)
%framingl
y=handles.y;
Fs=handles.Fs;
a=0.97;
y2=filter([1-a],1,y);
n=512 %Number of FAST FOURIER TRANSFORM points
Tf=(length(y))/Fs; %Frame duration in seconds
N=Fs*Tf; %Number of samples per frame
%fn=24; %Number of mel filters
l=length(y); %total number of sample speech
Ts=0.01; %Framse step in seconds
FrameStep=Fs*Ts; %Frame step in samples
noFrame=floor(1/FrameStep); %Maximum no of frames in speech sample
for i=1:noFrame
frame=y2((i-1)*FrameStep+1:(i-1)*FrameStep+N); %Holds individual frames
end
rata_frame = mean (frame);
set(handles.frameblocking,'string',rata_frame);
%figure;
%plot(frame(1,:));
handles.frame = frame ;
handles.rata_frame = rata_frame;
%proses.windowing
Fs=handles.Fs;
t=(1:512)'/Fs;
n=512;
f=n/t;
original=sin(2*pi*f*t)+0.2*randn(length(t),1);
windowed = original.*hamming(length(t));
rata_window = mean (windowed);
set (handles.windowing,'string',rata_window);
handles.rata_window = rata_window;
%FAST FOURIER TRANSFORM
Fs=handles.Fs;
a=0.97;
%y2=filter([1-a],1,y);
n=4096; %Power of 2 number of samples/length of FAST FOURIER TRANSFORM
%Get/Generate data
t=0:1/Fs:(n-1)/Fs; %n/fs sec sample
x=(1.3)*sin(2*pi*1500*t) ... % 1.5k Hz component
+ (1.7)*sin(2*pi*4000*(t-2)) ... %4.0k Hz component
+ (2.5)*randn(size(t));
%# Frequency Bins
bins = (0:1:n-1)*(Fs/n);
y = fast fourier transform (x,n);
rata_fast fourier transform = mean (y);
set (handles.fast fourier transform, 'string', rata_fast fourier transform);
handles.rata_fast fourier transform = rata_fast fourier transform;
%DISCRETE COSINE TRANSFORM
y=handles.y;
in _discrete cosine transform = f_fast fourier transform_(y);
% Input for a DISCRETE COSINE TRANSFORM Transform
k=0 : ( length (in_discrete cosine transform)-1);
%limits for Variable K tends to N-1.
ex=exp (-j*k*pi/length(in_discrete cosine transform)));
%Multiplaying Co-efficient.
in_discrete cosine transform = in_discrete cosine transform. *ex; %Point to point Multiplication.
in_descrete cosine transform=2*real(in_descrete cosine transform); % Extraction of Real-Part and Multiplaying with 2.
n=length(in_discrete cosine transform);
%Length of the input_dicrete cosine transform.
p=1:n; %To Get Even Symethric Output Waveform (DISCRETE COSINE TRANSFORM).
n=length (in_discrete cosine transform)/2;
%Length of the input_discrete cosine transform halved.
p=1:n; %samples halved
x(p)=in_discrete cosine transform (p);
%Storing valves in another Variable.
x;
rata_discrete cosine transform = mean (x);
set (handles. discrete cosine transform, 'string', rata_discrete cosine transform;
%Cepstrallifter
Fs=handles.Fs;
y2=handles.y2;
y2 = y2 (:,1); %get the first channel
xmax = max (abs(y2)); %find the maximum value
y2=y2/xmax; %scale the sinal
%time vector generation
N= length (y2);
t= (0:N-1)/Fs;
% cepstral analysis
[C,q] = cepstrum (y2,Fs);
handles.C = C;
%plot of the signal
figure;
subplot (2,,1,1)
plot (t,y2,'r')
xlim([0 max (t)])
ylim([-1.1*max(abs(y2)) 1.1*max(abs(y2))])
grid on
set (gca, 'FontName', 'Times New Roman', 'FontSize',12)
xlabel ('Time,s')
ylabel ('Normalized amplitude')
title ('The signal in the time domain')
%plot of the cepstrum
%1 ms minimum speech quefrency (1000 Hz) and 20 ms maximum speech qufrency(50 Hz)
subplot (2,1,2)
plot (q*1000, C, 'r');
grid on
xlim ([1 20])
set (gca, 'FontName', 'Times New Roman', 'FontSize', 12)
xlabel('Quefrency, ms')
ylabel('Amplitude')
title('Amplitude cepstrum of the signal(quefrencies from ms to 20 ms)')
%rata-rata nilai cepstrum
C=handles.C;
rata=mean(C);
handles.rata =rata;
set(handles.cepstrum, 'string',rata);
%handles.rata = rata;
%--- Executes on button press in uji_btn.
function uji_btn_Callback(h0bject,eventdata,handles)
% % a = data input training data dari excel
a=xlsread ('C:\Users\waf_r\Download\refsuara\input.xlsx','Sheet1');
cepstrum=handles.cepstrum
time1=handles.time1;
c=[cepstrum;time1;
t(1:3)=1; t(4:6)=2; t(7:9)=3; t(10:12)=4; t(13:15)=5; t(16:18)=6; t(19:21)=7; t(22:24)=8;
net = newff (a', t, [10 5], {'logsig', 'logsig'},'trainlm');
%melihat bobot, bobot akan diberikan secara acak oleh matlab
bobotawal_Input = net.IW(1,1);
bobotawal_bias_input = net.b(1,1);
%parameter training
net.trainParam.show = 25;
net.trainParam.epochs = 5000; %jumlah maksimum epoch
net.trainParam.goal = 0.00000000001; %nilai minimum error
net.trainParam.min_grad=le-10;
net.trainParam.max_fail=1000000000000000000000000000000000000000000000000000000
net.trainParam.Ir=0.01; %nilai learning rate
%training jaringan
net = train (net,a',t);
save net.mat
%uji jaringan;
y=sim(net,c');
y=round(y);
if (y==1)
set (handles.edithasil, 'String','Sa','Visible','on')
else if (y==2)
set (handles.edithasil, 'String','Sho','Visible','on')
else if (y==3)
set (handles.edithasil, 'String','Dza','Visible','on')
else if (y==4)
set (handles.edithasil, 'String','Za','Visible','on')
else if (y==5)
set (handles.edithasil, 'String','Qo','Visible','on')
else if ((y==6)
set (handles.edithasil, 'String','Ka','Visible','on')
else if (y==7)
set (handles.edithasil, 'String','A','Visible','on')
else if
set (handles.edithasil, 'String','^A','Visible','on')
end
%akurasi hasil training
X= round (sim(net,a'));
%hasil=(t,X);
n=length(t);
b=0;
%b=jumlah input yang memiliki nilai sama dengan target
for i=1:n
if X(i)==t(i)
b=b+1;
end
end
b;
ak=(b/n)*100;
disp (['accuracy JARINGAN SYARAF TIRUAN =',num2str(ak,'%2f'),'%'])
%% --- Executes on button press in play_ori_btn.
function play_ori_btn_Callback(h0bject, eventdata,handles)
y=handles.y;
Fs=handles.Fs;
sound(y,Fs);
% --- Executes on button press in play_emphasis_btn.
function play_emphasis_btn_Callback(h0bject, eventdata, handles)
%h0bject handle to play_emphasis_btn (see GCBO)
%eventdata reserved - to be defined in a future version of MATLAB
%handles structure with handles and user data (see GUIDATA)
y=handles.y;
a=0.97;
y2=filter([1-a],1,y);
Fs=handles.Fs;
sound(y2,Fs);
  2 个评论
yusuf rahmat
yusuf rahmat 2021-10-27
when I run this program error (Line: 80 Column: 18 Unexpected MATLAB expression.) I don't know what's wrong. my matlab version 2015a

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2021-10-27
This line:
y = fast fourier transform (x,n);
Why there are spaces? Is it a function or you mean
y = fft(x,n);
Note that there should be no spaces in the function name. Else you will get error. If this is a comment, comment it by %.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by