mupad sum a function with odd arguments
3 次查看(过去 30 天)
显示 更早的评论
This seems a simple operation but after searching all eventing I can't find anything that helps.
I want to create a sum of a function with index = odd integers. Nothing i do seems to work.
Cn := n->piecewise([testtype(n,Type::Odd),(4*V0)/(n*pi*sinh((n*pi*g)/f1))],[testtype(n,Type::Even), 0])
Vn := (x,y,n) -> Cn(n)*sinh((n*pi*y)/f1)*sin((n*pi*x)/f1)
V := (x,y,N)->sum(Vn(x,y,n),n=1..N)
the problem is that i can't find any way to get the piecewise function Cn to see n as either even or add, its always unknown. If i hard code a number in the V instead of n then it works. It seems amazing there is not some simple way to do a sum with only odd integers, but i ended up with this more complex method, but can't get it to work. I understand why Cn is not working, but i can't come up with any way to make it work. I suppose i could resort the a loop and not use sum, but that would feel like a failure at this point, and i am not sure it would not run into the same problem finding if numbers are even and odd.
I am ready to tear my hair out at this point!!
Thanks for any help here. jim
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with MuPAD 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!