How to solve following difference equation using Matlab

Hello,
Please help me to solve following difference equations using Matlab
p(n)= p(n-1) + (1- p(n-1)) * p(0)
p(n)= p(n-1) * gamma^k
with initial conditions
p(0) =1, gamma= [0,1]
also from both equations
gamma= (1-(1-p(n-1))/p(n-1)* p(0))^ (1/k).
How this can be solved and plot using Matlab.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 1 月 17 日

0 投票

You have gamma= [0,1] which is a vector. You have gamma^k . You cannot raise a vector to a power in MATLAB: you can only raise square matrices to a power. You could raise each element of the vector to a power, gamma.^k but that is going to return a vector result, which implies that the output of p(n) would have to be a vector, and then you would fail the multiplications the next time around. Unless you changed them to element-by-element multiplications...

カテゴリ

ヘルプ センター および File ExchangeGamma Functions についてさらに検索

質問済み:

2016 年 1 月 17 日

回答済み:

2016 年 1 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by