Error in MATLAB function

6 ビュー (過去 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 Center および File ExchangeArgument Definitions についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by