MATLAB
Given an integer N 25, construct the following square N N matrices in Matlab. The value of N is provided in the script. HINT: You might find one or more of the functions eye, zeros, ones, diag, flipud, fliplr useful. 1 2 3 4 N 0 1 0 0 N – 2 N-1 0 0 0 0 N-1 N-2 Aj = . : 0 0 1 0 : 0 0 0 0 0 0 0 0 : 0 1 : 2 1 0 0 1 2 3 4 N-2 N-1 N 1 0 0 0 0 0 1 1 1 0 0 0 0 0 A2 = .. : : : : 1 0 N N - 1 : 0 0 N – 2 N - 3 : 0 0 1 3 2 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 1 Az = 0 0 0 0 : : : : 0 1 0 0 . : : 0 0 1 1 1 1 1 1 1
ſo 1 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 : : : : 0 0 0 0 A4 . : 0 : 1 O... i 0 0 0 0 0 0 N – 2 N-1 N 1 2 3 4 1 0 0 0 0 2 0 0 0 O O -2 0 0 0 -2 1 -... 2 0 0 0 A5 = . : : : 0 0 -2 1 2 0 0 0 0 0 0 ... 0 -2 1 Assign matrices A1, A2, A3, A4, A3 to the variables named A1, A2, A3, A4, A5, respectively.
MATLAB
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am