I wanted to code the following into matlab the variables k is associated with the interval i=1:N
N=30
k=5-i+(N-3)
into the equation y but equation y is associated with another interval
i=1:N-2
y=2k*x(i+1)+3*x(i-1)
Do I have to write two for loops one for the k variable and one of the equation y
Thanks

2 Comments

What does "associated" mean to you?
For me it means I have to find K for the interval i=1:N and for y I have to find values for the interval i=1:N-2

Sign in to comment.

 Accepted Answer

N = 30
i = 1 : N;
k = 5-i+(N-3);
y = 2 .* k(1:N-2) .* x(i(1:N-2)+1) + 3 .* x(i(1:N-2)-1);

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Asked:

on 2 Dec 2017

Commented:

on 2 Dec 2017

Community Treasure Hunt

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

Start Hunting!