Errors occurred during parsing of MATLAB function 'MATLAB Function'
Show older comments
Hello,
I am trying to create a simulink model for a function in MATLAB and I keep getting the following error (Errors occurred during parsing of MATLAB function 'MATLAB Function'). I tried to declare the vectors to be zero before I start the for loop but still it did not work. The code for that part of the function is the following:
function p = shep(number_tones,f1,f2,tmax,sr)
% % PARAMETERS % %
%number_tones=3; % number of tones
%f1 = 25; % starting freq (Hz)
%f2 = (2^number_tones)*f1; % ending freq (Hz)
%f2 = 130.81; % %tmax=18; % duration (sec)
%sr=48100; % sample rate (samples/sec)
dt=1./sr; % time step
ns=tmax*sr; % number of sample/cycles
cycles=1; % number of cycles
% oct=log(f2/f1)/log(2.); % number of octaves
ntimes = ns*cycles; % t2=tmax; dur=tmax; % tpi=2.*pi; % rate=oct/dur; %
TT=linspace(dt,(ntimes+1)*dt,ntimes); %
a = zeros(1,ntimes);
arg = zeros(1,ntimes);
freq = zeros(1,ntimes);
a=zeros(1,ntimes);
theta=zeros(number_tones,1);
arg=zeros(number_tones,1);
key=zeros(number_tones,1);
noc=zeros(number_tones,1);
amp=zeros(number_tones,1);
% for i=1:number_tones
noc(i)=2^(i-1);
end %
fspan=f2-f1;
theta_coefficient=tpi/(rate*log(2));
%
sd=150;
for i=1:ntimes
% W=-1.+2^(rate*TT(i));
%
arg(1)=f1*W;
%
for j=1:number_tones
if(key(j)==0)
arg(j)=arg(1)*noc(j);
else
W=-1.+2^(rate*TT(i-key(j)));
arg(j)=f1*W;
end
end
%
for j=1:number_tones
fspectral=noc(j)*f1*(2^(rate*TT(i-key(j))));
delta=(fspectral-f1)/fspan;
amp(j)=(1-cos(tpi*delta));
%
if(fspectral>f2)
key(j)=i;
noc(j)=1;
end
end
%
theta=theta_coefficient*arg;
%
a(i)=sum(amp.*sin(theta));
%
end
%
a(1)=0.;
Thank you,
Tasos
1 Comment
Kaustubha Govind
on 19 Jun 2014
Please provide the additional error messages (they should point to the specific code that caused the failure).
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown 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!