フィルターのクリア

I need to sum the values around the perimeter of a matrix, is there sum function in matlab

1 回表示 (過去 30 日間)
DJ V
DJ V 2016 年 11 月 8 日
回答済み: Ibrahim Abouemira 2019 年 5 月 19 日
I assume there is a sum function and attempt the following code:
[x,y] =size(M)
Z = M(x:-1:1, y:-1,1);
  2 件のコメント
DJ V
DJ V 2016 年 11 月 8 日
make that: [x,y] = size(A); y = sum(A(1,1:1:y))+sum(A(y,1:1:y))+sum(A(2:1:X-1,1))+sum(A(2:1:x-1,y));
DJ V
DJ V 2016 年 11 月 8 日
[x,y] = size(A); y = sum(A(1,1:1:y))+sum(A(y,1:1:y))+sum(A(2:1:x-1,1))+sum(A(2:1:x-1,y));

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

回答 (2 件)

Daniel kiracofe
Daniel kiracofe 2016 年 11 月 11 日
For your second sum, instead of sum(A(y,1:1:y)) think you wanted sum(A(x,1:1:y))
  1 件のコメント
Vivek Kumar Chouhan
Vivek Kumar Chouhan 2018 年 4 月 20 日
this code works good for calculating perimeter of matrix of order higher than 2*2 but doesn't work for 2*2 matrix

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


Ibrahim Abouemira
Ibrahim Abouemira 2019 年 5 月 19 日

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by