Recording vectors in for loop, when the loop is running in a range starting with negative numbers
1 回表示 (過去 30 日間)
古いコメントを表示
I'm trying to record values of cn during a for loop, but I can't seem to index into a vector x using the value for the iteration, because my for loop is running from values -50:50. So It cant index into x at x(1,n). I have no idea how to solve this. Does anyone have any suggestions? Thank you!
clear; clc, clf;
t = 0:0.01:20;
A=2;
T=5;
wo = 2*pi()/T;
nmax = 50;
x = zeros(1,length(-nmax : 1 : nmax));
for n = -nmax : 1 : nmax;
if n ~=0
cn = (A/ (T*-1i*n*wo) ) * (exp(-1i*n*wo*T/2)-1);
else
cn = A/2;
end
x(1,n) = cn;
end
0 件のコメント
採用された回答
その他の回答 (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!