Programming a summation equation
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I am trying to program this instance
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/336283/image.jpeg)
This is my Fourier_Force
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/336286/image.jpeg)
using this code:
Z =3;
r = 2;
for j =1:1:size(Fourier_Force,1)
for q = 0:1:Z-1
Fourier_Force{j,1} = Fourier_Force{j,1} .* exp(-j*q*((2*pi)/3)*r) % Fourier_force has two values(x and y), thats why I used ".*"
Fourier_Force{j,1} = Fourier_Force{j,1} +Fourier_Force{j,1}
end
end
But it is not giving correct results, I am having problems in the loop and the summation part.
Does anybody know?
댓글 수: 0
답변 (1개)
Alan Stevens
2020년 7월 24일
Looks like you are trying to use j as both a loop counter and as sqrt(-1). I assume the latter is what is needed in the exponential function. If so, use i instead.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!