Too many output arguments error in my code
2 views (last 30 days)
Show older comments
I have the following code, I am trying to get all of the wavelet approximations out (it works fine with details, but not approximations).
I know what the error means, I just can't figure out how it applies in my code.
GRACE = load ('GRACE.txt')
ncol = size(GRACE,2);
for k = 1:ncol
[c,l] = wavedec(GRACE(:,k),6,'dmey');
cA6 = appcoef(c,l,'dmey',6);
[cD1,cD2,cD3,cD4,cD5,cD6] = appcoef(c,l,[1,2,3,4,5,6]);
D = [];
D(:,6) = wrcoef('d',c,l,'dmey',6);
D(:,5) = wrcoef('d',c,l,'dmey',5);
D(:,4) = wrcoef('d',c,l,'dmey',4);
D(:,3) = wrcoef('d',c,l,'dmey',3);
D(:,2) = wrcoef('d',c,l,'dmey',2);
D(:,1) = wrcoef('d',c,l,'dmey',1);
filename = sprintf('%s_%04f.txt', 'GRACE_APROXIMATIONS', k)
csvwrite(filename,D)
end
Any help would be greatly appreciated
1 Comment
Answers (1)
Walter Roberson
on 2 Jun 2015
Edited: Walter Roberson
on 2 Jun 2015
appcoef() only ever returns one variable. You are trying to get it to return 6.
If you are not passing a string representing the wavelet name, then you should be using either 4 or 5 arguments, with the 3rd and 4th being filters. Your [1,2,3,4,5,6] is being interpreted as a filter.
You cannot pass in a list of levels and get one output variable for each.
4 Comments
Stephen23
on 2 Jun 2015
Edited: Stephen23
on 2 Jun 2015
A = appcoef(C,L,'wname',N)
A = appcoef(C,L,'wname')
A = appcoef(C,L,Lo_R,Hi_R)
A = appcoef(C,L,Lo_R,Hi_R,N)
Count the outputs: each syntax shows exactly one output. You wrote this:
[cA1,cA2,cA3,cA4,cA5,cA6] = appcoef(c,l,[1,2,3,4,5,6]);
Count the outputs: there are six of them. The error message is telling you that you have too many outputs for this function: appcoef provides only one output.
To fix this you have to call appcoef in a loop, as Walter Roberson wrote.
See Also
Categories
Find more on Continuous Wavelet Transforms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!