Generate a matrix the shifts variables one column

1 回表示 (過去 30 日間)
Charles Unkrich
Charles Unkrich 2021 年 1 月 31 日
回答済み: weikang zhao 2021 年 2 月 1 日
I have a NxN matrix. I want to be able to define N and generate a matrix that follows this pattern. I am novice so please spare no detail.
  1 件のコメント
Adam Danz
Adam Danz 2021 年 1 月 31 日
I think you're looking for circshift. That link contains examples and descriptions.
If that's not what you're looking for, please elaborate.

サインインしてコメントする。

回答 (1 件)

weikang zhao
weikang zhao 2021 年 2 月 1 日
some error: The matrix given in the picture is a (N+1)*(N+1) matrix. The (2,0) element of the matrix is not given, I assume it is 0. This matrix looks like a Markov probability transition matrix, so I am not sure if qi here is a fixed value or i is a subscript of an array. I assume that these are all fixed values.
for example, if p0, qi,ri,pi&N are given, you can get the matrix you want by:
p0=0.2;
qi=0.3;
ri=0.4;
pi=0.5;
N=5;
temp=toeplitz([ri,qi,zeros(1,N-1)],[ri,pi,zeros(1,N-1)]).';
mat=[[1-p0,p0,zeros(1,N-1)];temp(2:end,:)];
have fun

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by