필터 지우기
필터 지우기

write this following matrix

조회 수: 1 (최근 30일)
Zeynep Toprak
Zeynep Toprak 2020년 5월 7일
댓글: Gokberk Yildirim 2020년 5월 16일
How can I write the following matrix
I define n=100
And I generate the following code
D= toeplitz ([0 1 zeros(1, n-2) -1]/ (2*h))
but I get wrong matrix. How can I correct it?
  댓글 수: 6
Zeynep Toprak
Zeynep Toprak 2020년 5월 7일
okay, thanks for helping, but it is very difficult. Thanks a lot again.
Gokberk Yildirim
Gokberk Yildirim 2020년 5월 16일
Actually, it can be done with this Zeynep.
c = [0 -1 zeros(1,n-3)];
r = [0 1 zeros(1,n-3)];
D = toeplitz(c,r) / (2*h)

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

채택된 답변

John D'Errico
John D'Errico 2020년 5월 7일
편집: John D'Errico 2020년 5월 7일
Try this:
n = 100;
D = (diag(ones(n-1,1),1) - diag(ones(n-1,1),-1))/(2*h);
You can also use spdiags. or sparse, or many other tools. But diag as I did it above is about the simplest way.
  댓글 수: 1
Zeynep Toprak
Zeynep Toprak 2020년 5월 7일
Many thanks for your great help!! :) I use this matrix in this question my question is here. But I get an error message. Please can you take a look at it? (This is not assignment or something else like this. On these lockdown days, I try to learn matlab by myself, and I have no one to ask or to learn) Many thanks again.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by