フィルターのクリア

matrix playing

3 ビュー (過去 30 日間)
PChoppala
PChoppala 2011 年 10 月 14 日
Hi all
i have
w1 =
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
1.0000 1.0002 1.0000 1.0001 1.0000 1.0001
I want a new matrix with product of all terms in each 2x2 matrix in w1
Eventually, I need a 1x3 matrix.
If I use prod(w1), only the columns get multiplied.
Can anyone help please

採用された回答

Walter Roberson
Walter Roberson 2011 年 10 月 14 日
blkproc(w1,[2 2],@prod)
  4 件のコメント
PChoppala
PChoppala 2011 年 10 月 14 日
Worked, but, just a quick question,
What is 'x'?
Walter Roberson
Walter Roberson 2011 年 10 月 14 日
x is the "formal argument" for the anonymous function. It is nearly exactly like the x in
proc result = multiplyblock(x)
result = prod(x(:));
end

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2011 年 10 月 14 日
Looks like a job for blockproc().
% Generate sample data.
w1 =[...
1.0000 4.0000 1.0000 2.0000 1.0000 6.0000;
1.0000 1.0002 1.0000 1.0001 1.0000 1.0001]
% Declare a function
fun = @(block_struct) prod(block_struct.data(:))
% Do the job:
result = blockproc(w1,[2 2], fun)
Note I changed w1 to make it easier to see that it actually did the job.
  1 件のコメント
PChoppala
PChoppala 2011 年 10 月 14 日
Worked!, many thanks mate!

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by