How to shift elements in matrix?

8 ビュー (過去 30 日間)
ASHA PON
ASHA PON 2023 年 1 月 25 日
コメント済み: ASHA PON 2023 年 1 月 25 日
I am having two matrix of size 7*7 and 7*1. Now, i need to compare these two matrix and alter entries in one matrix based on second matrix. Also, during computation, i need to consider first column of matrix A as last column and last row of matrix B as first row. The computation has to begin from second column of matrix A and last row of matrix B and ends with first column of matrix A and sixth row of matrix B. For example, second row second column of matrix A has element 1 and last row of matrix B has element 1, so expected output at matrix C is element 1 in second row of first column. Similarly, sixth row of third column in matrix A is 1 and element 1 is present in second row of matrix B, hence expected output at matrix C is element 1 in sixth row of second column and remaining terms are 0. Element 1 is present in fourth row of first column in matrix A and element 0 is present in sixth row of matrix B and hence, expected output at matric C is element 0 has to be present in fourth row of seventh column. Thank you in advance.
Example:
A=[0 0 0 1 0 0 0
0 1 0 0 0 0 0
0 0 0 0 1 0 0
1 0 0 0 0 0 0
0 0 0 0 0 1 0
0 0 1 0 0 0 0
0 0 0 0 0 0 1]
B=[1; 1; 0; 0; 1; 0; 1]
Expected output:
C=[0 0 1 0 0 0 0
1 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 1 0 0 0 0 0
0 0 0 0 0 1 0]
  3 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 1 月 25 日
Not another, same.
@ASHA PON, You have asked this type of question quite a few times now, and they all have been answered.
It's time to attempt something, before asking us to do your homework. You have the answers for your reference, in case you need any help.
ASHA PON
ASHA PON 2023 年 1 月 25 日
Thank you. I worked on the problem with small modifications and i got correct answer

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

採用された回答

Walter Roberson
Walter Roberson 2023 年 1 月 25 日
circshift()
  1 件のコメント
ASHA PON
ASHA PON 2023 年 1 月 25 日
Thank you Walter Roberson. I used this command and obtained output.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by