Short code for the expression

1 回表示 (過去 30 日間)
Tino
Tino 2019 年 5 月 1 日
コメント済み: Guillaume 2019 年 5 月 1 日
h =2;
P = [1, 4, 5, 7];
a1 = (1-h)* 1 + h * P(:, 1);
a2 = (1-h) * a1 + h * P(:, 2);
a3 = (1-h) * a2 + h * P(:, 3);
a4 = (1-h) * a3 + h * P(:, 4);
disp(a1) = 1
disp(a2) = 7
disp(a3) = 3
disp(a4) = 11
  2 件のコメント
Tino
Tino 2019 年 5 月 1 日
Please I will appreciate the answer to this question
thanks in advance
Guillaume
Guillaume 2019 年 5 月 1 日
To what question? You haven't asked anything, just given us some code with no explanation nor context.

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

採用された回答

madhan ravi
madhan ravi 2019 年 5 月 1 日
編集済み: madhan ravi 2019 年 5 月 1 日
a = num2cell( (1-h) * repmat( (1-h) * 1 + h * P(1), 1, 4) + h * P ) ;
[a1, a2, a3, a4] = deal( a{:} )
  6 件のコメント
Tino
Tino 2019 年 5 月 1 日
編集済み: Tino 2019 年 5 月 1 日
sorry the right figure is the one below. sorry for giving wrong computation
Can you help me with the short code to gives the following answers for h = any number for instance
when h = 1
1
4
5
7
when h = 2
1
7
7
3
when h = 3
1
10
1
13
thanks in advance
Guillaume
Guillaume 2019 年 5 月 1 日
In your question, you told us than when h = 2, a = [1 7 3 11] (for P = [1, 4, 5, 7]) and this is the answer that my code produces. I have no idea how you get your new answer. It doesn't match the formula you've posted.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by