Error in MATLAB function

1 次查看(过去 30 天)
Siddhartha Singh
Siddhartha Singh 2013-1-28
Hi! I am using following code as a function but there is some error occured
function [varargout]=deap(s)
%******************************
[C,L]=wavedec(s,4,'db4');%Scale 128
C4=appcoef(C,L,'db4',4);
D4=detcoef(C,L,4); %Scale 64
D3=detcoef(C,L,3);%Scale32
D2=detcoef(C,L,2);%Scale 16
D1=detcoef(C,L,1);%Scale 8
[C,L]=wavedec(s,4,'db4');
SRC4=wrcoef('a',C,L,'db4',4);
SRD4=wrcoef('d',C,L,'db4',4);
SRD3=wrcoef('d',C,L,'db4',3);
SRD2=wrcoef('d',C,L,'db4',2);
SRD1=wrcoef('d',C,L,'db4',1);
alpha=(SRD4);%?-wave(8~13Hz)
beta=(SRD3);%?-wave(14~30Hz)
varargout={alpha,beta,SRD1,SRD2,SRD3,SRC4,D1,D2,D3,D4,C4,C,L};
the error is *"Error in deap (line 3)
[C,L]=wavedec(s,4,'db4');%Scale 128
Output argument "y" (and maybe others) not assigned during call to "C:\Users\SID\Desktop\deap.m>deap"* Please help me any one . Thanks in advance.

回答(2 个)

Kaustubha Govind
Kaustubha Govind 2013-1-28
Your MATLAB Function block's Ports and Data Manager probably configures "y" as an output, which is never assigned in your function. Note that you cannot have a variable number of outputs for the MATLAB Function block, so you may instead what to replace varargout with (alpha,beta,SRD1,SRD2,SRD3,SRC4,D1,D2,D3,D4,C4,C,L) in your function prototype.
  2 个评论
Siddhartha Singh
Siddhartha Singh 2013-1-29
Thank you for giving your comment . After running this code then i went to command line and then just type y=deap(s); then got this error . Please clear me little bit more
Kaustubha Govind
Kaustubha Govind 2013-2-1
What about if you try Walter's solution?

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2013-1-29
T = {alpha,beta,SRD1,SRD2,SRD3,SRC4,D1,D2,D3,D4,C4,C,L};
for K = 1 : nargout
varargout{K} = T{K};
end

类别

Help CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by