matlab returning error message from dsp script

Status
Not open for further replies.

robismyname

Full Member level 6
Joined
Jan 17, 2008
Messages
390
Helped
11
Reputation
22
Reaction score
9
Trophy points
1,298
Location
Central Florida
Activity points
4,603
i get a error message from matlab saying:

??? function [b,a] = cas2dir(b0,B,A);
|
Error: Function definitions are not permitted in this context.

The script im using is coming from a book called DSP Using matlab 3rd edition.

The script is as follows:

Code:
function [b,a] = cas2dir(b0,B,A);
% CASCADE-to-DIRECT form conversion
% ---------------------------------
% [b,a] = cas2dir(b0,B,A)
% b = numerator polynomial coefficients of DIRECT form
% a = denominator polynomial coefficients of DIRECT form
% b0 = gain coefficient
% B = K by 3 matrix of real coefficients containing bk’s
% A = K by 3 matrix of real coefficients containing ak’s
%
[K,L] = size(B);
b = [1]; a = [1];
for i=1:1:K
b=conv(b,B(i,:)); a=conv(a,A(i,:));
end
b = b*b0;

The book came with a toolbox called "I&P_DSPUM_book_toolbox" that I had to download from the books website and then paste it in with the other toolbox folders in the programs toolboxes folder.

Can anyone tell me why Matlab returned the error messages? Is there a problem with matlab not recognizing the toolbox or is it something wrong with the script?
 
Last edited by a moderator:

It don't get the error.
Save the script as cas2dir.m in a folder in your Matlab path and try calling the function from the Matlab prompt.
 

function [b,a] = cas2dir(b0,B,A);

Is this how you're calling the function? If so, it's wrong, get rid of the 'function' keyword
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…