フィルターのクリア

How can I perform the following operation in matrix

1 回表示 (過去 30 日間)
dani elias
dani elias 2020 年 8 月 23 日
コメント済み: dani elias 2020 年 8 月 23 日
A=[2 3 4 5; 4 5 6 7; 3 4 5 6; 3 4 2 1] to get matrix B=[ 2 3 4 5; 4 20 18 7; 3 16 15 6; 3 4 2 1] the outer number remain as it was while the inner element is multiplied by the first row starting by the first element from the end. Matrix A is a square matrix of n dimensions. This is what I have tried so far
[m, n] = size(A); A= double(A);
for i=1:m
for j=1:n
if (j==1 && i==1)
B(i,j)= A(i,j);
elseif (i ==m && j==n)
B(i,j)= A(i,j);
else
B(i,j)= A(i,j+1) * A(i-1,n-j);
end
end
end

採用された回答

Bruno Luong
Bruno Luong 2020 年 8 月 23 日
編集済み: Bruno Luong 2020 年 8 月 23 日
If I understand correctly
>> A=[2 3 4 5; 4 5 6 7; 3 4 5 6; 3 4 2 1]
A =
2 3 4 5
4 5 6 7
3 4 5 6
3 4 2 1
>> B=A
B =
2 3 4 5
4 5 6 7
3 4 5 6
3 4 2 1
>> B(2:end-1,2:end-1)=B(2:end-1,2:end-1).*B(1,end-1:-1:2)
B =
2 3 4 5
4 20 18 7
3 16 15 6
3 4 2 1
  1 件のコメント
dani elias
dani elias 2020 年 8 月 23 日
thank you, this is what i was looking for

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

その他の回答 (0 件)

カテゴリ

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