Representing dinamyc Euller-Bernoulli beam matrix in matlab? -


how can represent in matlab left matrix dynamically, allowing me grow iterative given n.
enter image description here

given n, following code constructs matrix show, provided pattern stays same.

n = 5; d(n) = -12; d(1) = 12; d(2:end-1) = 6; b1(n-1) = 6; b1(1:end-1) = -4; b2(n-2) = 4/3; b2(1:end-1) = 1; a1 = b1(end:-1:1); a1(1) = -a1(1); = diag(d) + diag(b1, -1) + diag(b2, -2) + diag(a1, 1) + diag(b2(end:-1:1), 2) 

output n=5:

a =     12.0000   -6.0000    1.3333         0         0    -4.0000    6.0000   -4.0000    1.0000         0     1.0000   -4.0000    6.0000   -4.0000    1.0000          0    1.0000   -4.0000    6.0000   -4.0000          0         0    1.3333    6.0000  -12.0000 

output n=8:

a =     12.0000   -6.0000    1.3333         0         0         0         0         0    -4.0000    6.0000   -4.0000    1.0000         0         0         0         0     1.0000   -4.0000    6.0000   -4.0000    1.0000         0         0         0          0    1.0000   -4.0000    6.0000   -4.0000    1.0000         0         0          0         0    1.0000   -4.0000    6.0000   -4.0000    1.0000         0          0         0         0    1.0000   -4.0000    6.0000   -4.0000    1.0000          0         0         0         0    1.0000   -4.0000    6.0000   -4.0000          0         0         0         0         0    1.3333    6.0000  -12.0000 

to use sparse representation a can use pass command spdiags 4 arguments:

  1. a matrix b columns diagonals of a.
  2. a vector d such d(j) diagonal in a elements filled elements in b(:,j) (the j-th column of b).
  3. the number of rows in a.
  4. the number of columns in a.

i use names start a (above) super-diagonals , names start b (below) sub-diagonals (i don't use u (upper) , l (lower) because l looks lot 1 in editor). here relevant code.

n = 8; d(n, 1) = -12; d(1) = 12; d(2:n-1) = 6; bb1(n, 1) = 0; bb1(n-1, 1) = 6; bb1(1:n-2) = -4; bb2(n-1:n, 1) = 0; bb2(n-2, 1) = 4/3; bb2(1:n-3) = 1; aa1 = bb1(n:-1:1); aa1(2) = -aa1(2); aa2 = bb2(n:-1:1);  // sparse = spdiags([bb2 bb1 d aa1 aa2], -2:2, n, n);  // double-checking: converting full matrix should give constructed previous method. - full(as) // should 0 matrix 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -