Short code for the expression
1 view (last 30 days)
Show older comments
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 Comments
Guillaume
on 1 May 2019
To what question? You haven't asked anything, just given us some code with no explanation nor context.
Accepted Answer
madhan ravi
on 1 May 2019
Edited: madhan ravi
on 1 May 2019
a = num2cell( (1-h) * repmat( (1-h) * 1 + h * P(1), 1, 4) + h * P ) ;
[a1, a2, a3, a4] = deal( a{:} )
6 Comments
Guillaume
on 1 May 2019
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.
More Answers (0)
See Also
Categories
Find more on Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!