How to solve an equation with one variable (x) including a "sum" from 1:n?

4 ビュー (過去 30 日間)
Tim
Tim 2014 年 4 月 18 日
コメント済み: Mário Vieir 2018 年 7 月 7 日
Hi, I never used Matlab to solve simple equations, so it would be awesome if anyone could help me out:
I want to get to know "x", the "sum" is going from 1:n (so for example from 1:4..1,2,3,4). I've given data like:
K=[100 120 160 100]
Z=[100 100 170 700]
n=1:4
Variable: x
I want to solve this equation:
sum( (Z(n)/1.03^n) + ( ( x/4 - (x*(5-n)/4)*1.02) / 1.05^n ) == 0 )
Is that possible with Matlab? I tried the smys x and solve() function but that didn't work...
Thanks a lot!

採用された回答

Mischa Kim
Mischa Kim 2014 年 4 月 18 日
編集済み: Mischa Kim 2014 年 4 月 18 日
Tim, is the sum of all the 4 equation terms supposed to be equal to zero? If so, this should do
syms x
sol = vpa(sum((Z./1.03.^n) + ((x/4 - (x.*(5-n)/4)*1.02)./1.05.^n )) == 0)
  2 件のコメント
Tim
Tim 2014 年 4 月 18 日
Mischa, Thank you so much, that works perfectly fine! Thanks a lot!
Mário Vieir
Mário Vieir 2018 年 7 月 7 日
Thank you.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by