Too many output arguments error in my code
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2015 年 6 月 2 日
編集済み: Walter Roberson
2015 年 6 月 2 日
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 件のコメント
Stephen23
2015 年 6 月 2 日
編集済み: Stephen23
2015 年 6 月 2 日
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.
参考
カテゴリ
Help Center および File Exchange で Continuous Wavelet Transforms についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!