Double summation in matlab

I would like to do this double summation . where alpha=2; beta=1.5;
I am confuse about the command availbale in online .Pl somebody help me what is way of solving this summation.

1 comentario

Walter Roberson
Walter Roberson el 5 de Mzo. de 2020
Because you used addition here where the original question used multiplication.

Iniciar sesión para comentar.

 Respuesta aceptada

Mohammad Sami
Mohammad Sami el 5 de Mzo. de 2020

1 voto

You can define a function to calculate the expression inside the brackets.
a = @(p,param)param.^p./factorial(p); % (param^n)/factorial(n)
% param is alpha or beta, p = n or m
sum(sum(a(0:10,2)' * a(0:15,1.5)))

11 comentarios

AVM
AVM el 5 de Mzo. de 2020
Thanks. Then shall I have to do it separtely? and then multiply the two things?
AVM
AVM el 5 de Mzo. de 2020
Pl give the complete coding if possible.
AVM
AVM el 5 de Mzo. de 2020
clc;
clear;
syms n m
alpha=2;
beta=2;
f=@(n,m)(alpha.^n)+(beta.^m);
symsum(symsum(f,n,0,3),m,0,3)
Why this coding gives the result 120 insted of 30. Pl help me.
Mohammad Sami
Mohammad Sami el 5 de Mzo. de 2020
This is missing the factorial in the divisor.
Mohammad Sami
Mohammad Sami el 5 de Mzo. de 2020
Its already complete. I just put the multiplication and sum in one line
Mohammad Sami
Mohammad Sami el 5 de Mzo. de 2020
I think 120 is the correct answer.
a = @(p,param)param.^p; % (param^n)/factorial(n)
% param is alpha or beta, p = n or m
sum(sum(a(0:3,2)' + a(0:3,2)))
I don't have the symbolic toolbox myself so can't test it.
AVM
AVM el 5 de Mzo. de 2020
@sami: Thanks. Actually I was wrong. I have done a mistake in analytic calcualtion. It's working.
AVM
AVM el 5 de Mzo. de 2020
Editada: AVM el 5 de Mzo. de 2020
@Sami: I am trying to solve the following case according to your code of my previous problem, I am little bit confuse how to handle it. Pl help me.
clc;
clear;
syms alpha r1 theta mu nu lambda t n1 m1 theta2
r2=1.0;
theta2=2.0;
alpha1=0.5;
alpha2=1.0;
lambda=2.0;
omega=1;
phi=pi/3;
mu=cosh(r2);
nu=exp(1i*theta2).*sinh(r2);
f=((((alpha1.*exp(-1i*omega*t))*r1.*exp(-1i*theta)).^(n1))*(((alpha1.*exp(1i*omega*t))*r1.*exp(1i*theta)).^(m1))./(factorial(m1).*factorial(n1))).*...
1./sqrt((((mu).^2)-((abs(nu)).^2).*exp(-2*1i*lambda*t*(n1-m1)))).*...
exp(((1./mu).*exp(-2*1i*lambda*t*(n1-m1)).*real(((alpha2).^2)*conj(nu))+((alpha2).^2).*(exp(-1i*lambda*t*(n1-m1))))./...
(((mu).^2)-((abs(nu)).^2).*exp(-2*1i*lambda*t*(n1-m1))));
Now I would like to evaluate this double summation fucntion 'f' over n1 and m1 from 0 to 20 each of them. Pl help me to do that
Mohammad Sami
Mohammad Sami el 5 de Mzo. de 2020
I believe you should be able to solve this with the symbolic toolbox. I dont have the toolbox to check if it works.
Similar to what you posted earlier. Since only m1, n1 and t don't have a fixed value, only declare those as symbols.
Declare f as a function.
% your ealier post.
syms n m
alpha=2;
beta=2;
f=@(n,m)(alpha.^n)+(beta.^m);
symsum(symsum(f,n,0,3),m,0,3)
for the current question
syms n1 m1 t
r2=1.0;
theta2=2.0;
alpha1=0.5;
alpha2=1.0;
lambda=2.0;
omega=1;
phi=pi/3;
mu=cosh(r2);
nu=exp(1i*theta2).*sinh(r2);
f=@(n1,m1)((((alpha1.*exp(-1i*omega*t))*r1.*exp(-1i*theta)).^(n1))*(((alpha1.*exp(1i*omega*t))*r1.*exp(1i*theta)).^(m1))./(factorial(m1).*factorial(n1))).*...
1./sqrt((((mu).^2)-((abs(nu)).^2).*exp(-2*1i*lambda*t*(n1-m1)))).*...
exp(((1./mu).*exp(-2*1i*lambda*t*(n1-m1)).*real(((alpha2).^2)*conj(nu))+((alpha2).^2).*(exp(-1i*lambda*t*(n1-m1))))./...
(((mu).^2)-((abs(nu)).^2).*exp(-2*1i*lambda*t*(n1-m1))));
symsum(symsum(f,n1,0,20),m1,0,20)
Atrolita afra
Atrolita afra el 29 de Mzo. de 2020
can you please help me to plot this equation?
Atrolita afra
Atrolita afra el 29 de Mzo. de 2020
other information and the figure is here

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

AVM
el 5 de Mzo. de 2020

Comentada:

el 29 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by