Matlab sum sign inside for loop

I am trying to implement the following loop inside of matlab

enter image description here

The difficulty I am having is implementing the sum sign such that I get the correct values. The first row of my X matrix is correct but the second row is not and I cant figure out why.

J = [200 100 300];
k = [3e6 2e6 4e6];
n = 3;
points = 300;
for j = 1:points w(j)=j;
end
x = zeros(n+1,points);
x(1,:)=1;
for j = 1:points sumJx = 0; for i = 2:n+1 sumJx = sum(J(1:i-1)*x(1:i-1,j)); x(i,j) = x(i-1) - (w(j)^2 / k(i-1)) * sumJx; end
end
f_omega = x(n+1,:);
plot(w,f_omega);
ylim([-40 3])
1 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like