How to write a function with a for loop
2 次查看(过去 30 天)
显示 更早的评论
if t(i)=L1*(i-1)+ L[(i-1)/e]*t_k
i get
t1=0;
t2=L1;
t3=2*L1+t_k;
t4=3*L1+t_k;
where e=2 and i want to have a floor function for L[ (i-1)/e].How to create a function for the following with input e,imax,L1 and t_k like function delay(e,imax,L1,t_k) with a for loop
2 个评论
采纳的回答
Guillaume
2018-7-4
What's stopping you from trying? You'll quickly find out that it errors.
t = zeros(imax);
or probably better
t = zeros(1, imax);
would get rid of the error. Whether or not it's what you want, I don't know.
Note that the same can be achieved without a loop:
im = 0:imax - 1;
t = L1 * im + round(im /e) * t_k;
更多回答(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!