필터 지우기
필터 지우기

How to code this loop

조회 수: 2 (최근 30일)
Maryal
Maryal 2017년 12월 2일
댓글: Maryal 2017년 12월 2일
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
Image Analyst
Image Analyst 2017년 12월 2일
What does "associated" mean to you?
Maryal
Maryal 2017년 12월 2일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2017년 12월 2일
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);
  댓글 수: 1
Maryal
Maryal 2017년 12월 2일
Thanks Walter

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by