Trying to write a script to calculate a sum
6 次查看(过去 30 天)
显示 更早的评论
Can somebody show me how to write a script to calculate the following function of N? It just confuses me a bit because if N is an even number then it may very well be the the lower and upper index are not integers... I don't know what the best way to deal with this hurdle is, perhaps make the function go from a negative integer to a positive integer then make a necessary substitution??
I'm not sure.. But i'd love to see what you guys come up with. I'm slowly learning how to write basic programs, but this one is a bit out of my league, and I'd appreciate if somebody could show me how

p.s. how do I make the LaTeX formatting turn on??
4 个评论
David Hill
2020-9-26
编辑:David Hill
2020-9-26
Works fine for N (odd). Where did you get the equation? Are you sure there is not another equation for N (even). The above equation does not work for N (even).
采纳的回答
Alan Stevens
2020-9-26
Simply let k = 2j and then you can write:

This will hold for both N even and N odd.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!