Error in MATLAB function

2 Ansichten (letzte 30 Tage)
Siddhartha Singh
Siddhartha Singh am 28 Jan. 2013
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.

Antworten (2)

Kaustubha Govind
Kaustubha Govind am 28 Jan. 2013
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 Kommentare
Siddhartha Singh
Siddhartha Singh am 29 Jan. 2013
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 am 1 Feb. 2013
What about if you try Walter's solution?

Melden Sie sich an, um zu kommentieren.


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

Kategorien

Mehr zu Argument Definitions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by