필터 지우기
필터 지우기

PLEASE HELP ME FIX THIS::Function definitions are not permitted in this context.

조회 수: 3 (최근 30일)
Can some1 please help me. I have been trying to run this codes but getting a :: Function Definition not permitted.
HERE IS THE CODE.
>> %**************************************************************
% Filename : analysisFB.m
% Author : Necs
% Date : Aug 2014
% Purpose : Reconstruct the image using 2D forward discrete wavelet transform
%**************************************************************
function wc = analysisFB(data,lpfilter,hpfilter)
[n_row,n_col] = size(data);
n = n_row;
le = length(lpfilter);
%###################### operation on the rows ##############################
pad_data = [data data(:,1:le)];
lpcoeff = downsampleConv(pad_data,lpfilter,le,n);
hpcoeff = downsampleConv(pad_data,hpfilter,le,n);
%transpose the matrix
data = [lpcoeff hpcoeff]';
%###################### operation on thecolumns###########################
pad_data = [data data(:,1:le)];
lpcoeff = downsampleConv(pad_data,lpfilter,le,n);
hpcoeff = downsampleConv(pad_data,hpfilter,le,n);
%transpose the matrix again
wc = [lpcoeff,hpcoeff]';
return;
%local function
function downsample_coeff = downsampleConv(coeff,filter,le,n)
downsample_coeff = conv2(coeff,filter);
downsample_coeff = downsample_coeff(:, le:2:(le+n -1));
return;
Function definitions are not permitted in this context.
>> I also tried removing the function as illustrated in the example above but still giving an error

채택된 답변

Walter Roberson
Walter Roberson 2014년 3월 23일
You need to save the code to a file named analysisFB.m
  댓글 수: 2
Necs
Necs 2014년 3월 23일
Still thesame It complains that ::
??? function wc = analysisFB(data,lpfilter,hpfilter)
|
Error: Function definitions are not permitted in this context.
>>
Walter Roberson
Walter Roberson 2014년 3월 23일
In the file, before it, you can only have blank lines and comment lines. The ">>" should be deleted if it is in the file at the beginning.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

John D'Errico
John D'Errico 2014년 3월 23일
You appear to be trying to use a script file, with a function embedded in it.
The error message tells the story. Scripts cannot include function definitions of this sort.
Solution: The function must be saved as a separate m-file.
  댓글 수: 1
Necs
Necs 2014년 3월 23일
Thankz anyway.
But i still dnt get it because am kind of new to this programming. If u can guide me through how to make it run properly, i will so much appreciate it.
Thanks

댓글을 달려면 로그인하십시오.


Necs
Necs 2014년 3월 23일
Thankz anyway.
But i still dnt get it because am kind of new to this programming. If u can guide me through how to make it run properly, i will so much appreciate it.
Thanks

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by