Help understand the sumsqr algorithm

10 ビュー (過去 30 日間)
Brian
Brian 2014 年 11 月 21 日
コメント済み: Image Analyst 2014 年 11 月 21 日
For a current project, I've begun switching between versions of matlab. For my trial of 2014, I guess I didn't download the neural network toolbox, so I can't use sumsqr. When I used it on my other version I got what might be called an "impossible" answer.
In the study of wavelet compression techniques, one expects the original picture and the wavelet transform image to have the same energy. Energy is defined as the sum of squared elements of thee matrix. When I computed sumsqr on my MATLAB 2008, I got two different answers.
In order to try and understand the problem, I have 2 requests for the user community 1. Help me understand sumsqr. Does it square entries first, or sum the matrix first? 2 Is there code for qhat I want to do? That is, square the elements first, then sum them.
  1 件のコメント
Brian
Brian 2014 年 11 月 21 日
Some clarification: Since 2014 does most of what I want, I would like to know how to sum squared elements without the Neural Network Toolbox

サインインしてコメントする。

採用された回答

Greg Heath
Greg Heath 2014 年 11 月 21 日
help sumsqr
doc sumsqr
type sumsqr
Thank you for formally accepting my answer
Greg
  2 件のコメント
Brian
Brian 2014 年 11 月 21 日
Do I write those into MATLAB or search on math works?
Image Analyst
Image Analyst 2014 年 11 月 21 日
Type then at the >> prompt in the command window.

サインインしてコメントする。

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2014 年 11 月 21 日
If you consult the site
http://www.mathworks.com/help/nnet/ref/sumsqr.html
you will see that 'sumsqr' returns with the sum of the squares of all finite elements of a matrix (or cell array of matrices,) as well as their number. For a matrix the following code should suffice, though it might not be as efficient as Mathworks' function. To make it work for cell arrays would require some modifications which I leave to you.
function [s,n] = sumsqr(x)
x = x(:);
t = isfinite(x);
s = sum(x(t).^2);
n = sum(t);
return

カテゴリ

Help Center および File ExchangeDiscrete Multiresolution Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by