How to have matrix values as a function of another variable

1 回表示 (過去 30 日間)
Andrew Poissant
Andrew Poissant 2017 年 2 月 17 日
コメント済み: Andrew Poissant 2017 年 2 月 17 日
I have a matrix P (defined below) that has some values (h and u) that are a function of a variable t. t have values ranging from 1 to 50. When I define h and n as a function of t and insert them into the matrix I get an error saying "Dimensions of matrices being concatenated are not consistent." How to I fix this issue?
t = 1:50;
h = 0.9*exp(-2*t);
u = 0.9*(1-exp(-2*t));
N = 4;
P = [0.1 h 0 0 0 ; ...
u 0.1 h 0 0; ...
0 u 0.1 h 0; ...
0 0 u 0.1 h; ...
0 0 0 u 0.1];

採用された回答

Rahul Kalampattel
Rahul Kalampattel 2017 年 2 月 17 日
編集済み: Rahul Kalampattel 2017 年 2 月 17 日
h and u are vectors since t is also a vector, hence why you get the error when trying to put them into the matrix P.
Do you want a different P matrix for each value of t?
  4 件のコメント
Andrew Poissant
Andrew Poissant 2017 年 2 月 17 日
The number of P matrices are what I am looking for (not looking for 3D matrix). However, all of the values in the matrices are the same, even though the values of h and u should change with the iteration number (aka time). Do you know why the values are remaining the same?
Andrew Poissant
Andrew Poissant 2017 年 2 月 17 日
nvm, the values just converge very soon in the iterations. thanks!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by