필터 지우기
필터 지우기

Order a matrix A 4x4 in another matrix B 6x6

조회 수: 2 (최근 30일)
JOSUE PÁNCHEZ
JOSUE PÁNCHEZ 2021년 11월 24일
편집: DGM 2021년 11월 24일
I want to insert elements of my matrix R1(1,1); R1(1,2); ...R1(i,j) in specific positions in my matrix G=zeros(6)
G=zeros(6)
R1=[0.1680 0.8400 -1.6800 0.8400
0.8400 5.6000 0.8400 2.8000
-0.1680 -0.8400 0.1680 -0.8400
0.8400 2.8000 -0.8400 5.6000]
G(i,j)=G(i,j)+R1(i1,j1)
G
So I want in G(3,3) the value of R1(1,1), in G(3,4) the value of R1(1,2) and so on, I dont know how to do a code for that
If you could help me I'd appreciate it

답변 (1개)

DGM
DGM 2021년 11월 24일
편집: DGM 2021년 11월 24일
Something like this:
G = zeros(6);
R1 = [0.1680 0.8400 -1.6800 0.8400
0.8400 5.6000 0.8400 2.8000
-0.1680 -0.8400 0.1680 -0.8400
0.8400 2.8000 -0.8400 5.6000];
% your example shows the sum
G(3:end,3:end) = G(3:end,3:end)+R1 % if you want the actual sum
G = 6×6
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1680 0.8400 -1.6800 0.8400 0 0 0.8400 5.6000 0.8400 2.8000 0 0 -0.1680 -0.8400 0.1680 -0.8400 0 0 0.8400 2.8000 -0.8400 5.6000
% alternatively
G(3:end,3:end) = R1 % if you just want to replace that part of G

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by