Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Error using fgen Too many input arguments.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
For a project I was given the following code to start with but I am getting this message: "Error using fgen Too many input arguments."
%EDELWE1 This is the main program that creates the digitized
% sound for the first seven notes of the song "Edelweiss"
%
% First we set the frequency of each note (in the scale
% ranging from Ab to Gs, where 'b' stands for Flat and
% 's' stands for Sharp). Then we mark the beginning and
% end of each note. Next, the function FGEN is called
% to generate a Sinewave of appropriate frequency and
% duration. Also. a little "rest", i.e., silence,
% is provided between a pair of successive notes
% in order to make them stand apart.
% Define frequencies corresponding to different notes
s=2^(1/12);
a=220;
ab=a/s;
as=a*s;
b=as*s;
c=b*s;
cs=c*s;
d=cs*s;
ds=d*s;
e=ds*s;
f=e*s;
fs=f*s;
g=fs*s;
gs=g*s;
eH=2*e; % eH = one octave higher note of "E"
csH=2*cs; % csH = one octave higher note of "C sharp"
dsH=2*ds;
% define sampling rate and note durations
dt=1/8000; % dt = sampling interval
%rest=0.1;
rest=0.2; % rest = a period of silence between two notes
t4=1.0; % t4 = duration of a quarter note.
t8=t4/2;
t2=t4*2;
% create the digitized musical score
z=[]; % z = vector that stores sampled musical score
ti=0; % ti = time when the first note starts
tf=ti+t4; % tf = time when the first note ends
y=fgen(e,ti,tf); % y = sampled data representing note "e"
z=[z;y]; % Store y into vector z
ti=tf+dt; % ti = time when pause begins
tf=ti+rest; % tf = time when pause ends
y=fgen(0,ti,tf); % sets y = 0
z=[z;y]; % stores y into vector z
ti=tf+dt; % ti = time when the second note begins
tf=ti+t8; % tf = time when the second note ends
y=fgen(g,ti,tf); % y = sampled data representing note "g"
z=[z;y]; % store y into vector z
ti=tf+dt; % follow a similar procedure from here
tf=ti+(rest/4);
y=fgen(0,ti,tf);
z=[z;y];
ti=tf+dt;
tf=ti+t4;
y=fgen(dsH,ti,tf);
z=[z;y];
ti=tf+dt;
tf=ti+t8;
y=fgen(0,ti,tf);
z=[z;y];
ti=tf+dt;
tf=ti+t4;
y=fgen(csH,ti,tf);
z=[z;y];
ti=tf+dt;
tf=ti+rest;
y=fgen(0,ti,tf);
z=[z;y];
ti=tf+dt;
tf=ti+t8;
y=fgen(g,ti,tf);
z=[z;y];
ti=tf+dt;
tf=ti+rest;
y=fgen(0,ti,tf);
z=[z;y];
ti=tf+dt;
tf=ti+t4;
y=fgen(f,ti,tf);
z=[z;y];
% play it using MATLAB's sound function
Fs=1/dt; % Fs = sampling rate
soundsc(z,Fs) % sound function plays the musical score
% FGEN This is the function generator routine
% that is called by EDELWEISS to generate
% sinewaves of different frequencies
% and varying durations
function y=fgen(f,ti,tf)
dt=1/8000;
t=[ti:dt:tf]';
y=sin(2*pi*f.*t);
1 Commento
Risposte (1)
Ankitha Kollegal Arjun
il 17 Apr 2017
The custom function name might be causing the issue.
There is a MATLAB in-built function by the name 'fgen', and your code also defines a function having the same name. Try renaming your custom function.
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!