I want to change matrix like below picture.
How can I do?
Thanks :)

 Accepted Answer

KSSV
KSSV on 16 Mar 2022
Edited: KSSV on 16 Mar 2022
A = rand(4)
A = 4×4
0.2474 0.1371 0.8875 0.6324 0.2656 0.0413 0.9122 0.4274 0.4822 0.9391 0.8935 0.8856 0.9399 0.0016 0.7617 0.4273
iwant = zeros(6) ;
iwant(1:4,1:4) = A
iwant = 6×6
0.2474 0.1371 0.8875 0.6324 0 0 0.2656 0.0413 0.9122 0.4274 0 0 0.4822 0.9391 0.8935 0.8856 0 0 0.9399 0.0016 0.7617 0.4273 0 0 0 0 0 0 0 0 0 0 0 0 0 0
B = iwant ;
iwant = B(1:4,1:4)
iwant = 4×4
0.2474 0.1371 0.8875 0.6324 0.2656 0.0413 0.9122 0.4274 0.4822 0.9391 0.8935 0.8856 0.9399 0.0016 0.7617 0.4273

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 16 Mar 2022

Edited:

on 16 Mar 2022

Community Treasure Hunt

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

Start Hunting!