how to develop n order matrix?

조회 수: 1 (최근 30일)
Jasneet Singh
Jasneet Singh 2021년 3월 19일
댓글: Jan 2021년 3월 22일
i wish to make a matrix of nth order fromm K=[2000,-1000,0,0;-1000,2000,-1000,0;0,-1000,2000,-1000;0,0,-1000,1000; so on to nth order]
can anyone please help me with this ...
  댓글 수: 3
Jasneet Singh
Jasneet Singh 2021년 3월 19일
편집: Jan 2021년 3월 19일
its because last element is not hinged or fixed. so, there is only 1 force=1000 acting on it.
Walter Roberson
Walter Roberson 2021년 3월 19일
K=[2000,-1000,0,0;-1000,2000,-1000,0;0,-1000,2000,-1000;0,0,-1000,1000]
K = 4×4
2000 -1000 0 0 -1000 2000 -1000 0 0 -1000 2000 -1000 0 0 -1000 1000

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2021년 3월 19일
편집: Jan 2021년 3월 19일
With some guessing: You want a tridiagonal matrix with the right bottom element changed. Then:
n = 4;
K = diag(repmat(2000, 1, n)) + ...
diag(repmat(-1000, 1, n-1), 1) + ...
diag(repmat(-1000, 1, n-1), -1)
or
K = zeros(n, n);
nn = n * n;
n1 = n + 1;
K( 1:n1:nn) = 2000;
K(n1:n1:nn) = -1000;
K( 2:n1:nn-n) = -1000;
or
K = toeplitz([2000, -1000, zeros(1, n - 2)])
or
K = full(gallery('tridiag', n, -1000, 2000, -1000))
or
K = conv2(eye(n), [-1000, 2000, -1000], 'same')
any finally:
K(n, n) = 1000;
Or directly:
K = diag([repmat(2000, 1, n - 1), 1000]) + ... % Last element adjusted
diag(repmat(-1000, 1, n - 1), 1) + ...
diag(repmat(-1000, 1, n - 1), -1)
  댓글 수: 7
Jasneet Singh
Jasneet Singh 2021년 3월 22일
specifically for x w.r.t omega..
Jan
Jan 2021년 3월 22일
This is a new question. Please post it as a new thread.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2021년 3월 19일
n = 7;
MD = 2000*ones(1,n);
SD = -1000*ones(1,n-1);
K = diag(MD) + diag(SD,1) + diag(SD,-1)
K = 7×7
2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000
Or:
n = 7;
K = zeros(n,7);
K(1:n+1:end) = 2000;
K(2:n+1:end) = -1000;
K(n+1:n+1:end) = -1000;
K
K = 7×7
2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000 -1000 0 0 0 0 0 -1000 2000

카테고리

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