Effacer les filtres
Effacer les filtres

mupad sum a function with odd arguments

3 vues (au cours des 30 derniers jours)
james hopper
james hopper le 2 Nov 2014
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

Réponses (0)

Catégories

En savoir plus sur Get Started with MuPAD dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by