How to write the given equation in matlab?

I already got the h0a k0 r0 and p0 but I ran into issues writing the line of code. For n , 0 ≤ n <length(h0a), and for J, J=length(r0). How can I write this equation in matlab?

2 Comments

did you try writing anything? show us what have you tried.
syms k
J = length(r0);
for n=1:length(h0a)
h0a = k0(n) + symsum(r0(k)*(p0(k))^n, k, 0, J-1);
end

Sign in to comment.

Answers (1)

I have assumed the values of r_0, p_0 and k_0. This is the command, as per your attached picture. I am not able to understand your question completely.
r
_0=[1 2 3 4 5];
p_0=[8 9 5 6 5];
k_0=[10:10:90];
for n=1:length(k_0)
B=0;
for i=1:length(r_0)-1
A=r_0(i)*((p_0(i))^n) ;
B=B+A;
end
h_ob(n)=B+k_0(n)
end

Categories

Products

Asked:

on 3 Nov 2017

Answered:

on 2 Dec 2017

Community Treasure Hunt

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

Start Hunting!