How to implement a for loop over a specified range?
显示 更早的评论
Outputs:
- t: time vector ranging from Start to End with a sampling rate of fs
- X: sum of sinusoids over the specified range
The code I am using for my outputs is:
t = linspace(Start,End,fs);
X=0;
for i=1:N
X = X + A(i)*cos(2*pi*f(i)*t + phi(i)) + B(i);
end
I keep getting an error: Attempted to access B(2); index out of bounds because numel(B)=1. Need help fixing it.
2 个评论
Walter Roberson
2016-2-27
We do not know how you initialized B, or what it is intended to mean.
Did you happen to compute B using the "/" operator?
Brian Aguilar
2016-3-1
编辑:Walter Roberson
2016-3-1
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!