Symsum function with odd number and infinity upper limit
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I'm trying to do a sum series of the following equation with odd numbers and infinity upper limit.
When running the following code, i have a littteral value not a unique value which display in the command window. How can i do to have a unique value in a variable? How can i define the calculation with infinity upper limit and odd number? Please
The aim is to be able to plot the distribution of p over x and y.
%% Analytical calculation
clear all
close all
clc
%% Input data
f = 15; % frequency [Hz]
omega = 2*pi.*f; % angular frequency
ho = 0.3*1e-3/2; % air gap height [m]
mu = 18.1e-6; % dynamic viscosity [Ns/m2]
rhoo = 1.206; % mean density [Kg/m3]
Co = 343; % undisturbed speed of sound [m/s]
Cp = 1004; % specific heat at constant pressure [J/KgK]
Cv = 716; % specific heat at constant volume [J/KgK]
lambda = 25.6e-3; % thermal conductivity [W/mK]
lx = 250*1e-3/2; % half length of plate [m]
ly = 180*1e-3/2; % half width of plate [m]
h = 0.05.*1e-3; % displacement amplitude
po = 1.01e5; % ambient pressure [N/m2]
%% Dimensionless Parameters
s = ho.*sqrt(rhoo.*omega./mu); % shear wave number
k = omega.*ho./Co; % reduced frequency
sigma = sqrt(mu.*Cp./lambda); % square root of Prandtl number
g = ho./lx; % nawroness of the gap
gamma = Cp/Cv; % ratio of specific heats
a = ly/lx; % aspect ratio of the panel
kx = omega*lx/Co; % normalised wave number along x-axis
ky = omega*ly/Co; % normalised wave number along y-axis
Bs =(tanh(s.*sqrt(i))./(s.*sqrt(i)))-1;
Bssigma =(tanh(s*sigma.*sqrt(i))./(s*sigma.*sqrt(i)))-1;
nssigma = (1+((gamma-1)/gamma).*Bssigma).^(-1);
Gamma = sqrt(gamma/(nssigma*Bs));
Ceffs = Co.*sqrt(nssigma.*Bs/gamma); % effective speed sound [m/s]
syms x y q
x = 1
y = 1
D = sqrt(((q*pi/(2*a))^2) - (kx*Gamma)^2);
SUMp=0;
a=1:2:9;
for jj=1:length(a)
p = (2*nssigma*Gamma^2*kx*ky*h/pi).*symsum((((-1)^((q-1)/2)/(q*(D)^2)))*((cosh(D*x/kx)/cosh(D))-1)*cos(q*pi*y/(2*ky)),q,a(jj),a(jj));
SUMp=SUMp+p;
end
pretty(SUMp);
2 Kommentare
Dyuman Joshi
am 24 Mär. 2023
If you want a numeric value as output, use a numeric data-type. And as you are dealing with large floating point numbers, double() would be the better choice.
"How can i define the calculation with infinity upper limit and odd number"
Let K=1 to Inf, Then 2*K-1 will be 1, 3, 5, .... Inf
Why is effective speed sound a complex value?
%% Analytical calculation
%% Input data
f = 15; % frequency [Hz]
omega = 2*pi.*f; % angular frequency
ho = 0.3*1e-3/2; % air gap height [m]
mu = 18.1e-6; % dynamic viscosity [Ns/m2]
rhoo = 1.206; % mean density [Kg/m3]
Co = 343; % undisturbed speed of sound [m/s]
Cp = 1004; % specific heat at constant pressure [J/KgK]
Cv = 716; % specific heat at constant volume [J/KgK]
lambda = 25.6e-3; % thermal conductivity [W/mK]
lx = 250*1e-3/2; % half length of plate [m]
ly = 180*1e-3/2; % half width of plate [m]
h = 0.05.*1e-3; % displacement amplitude
po = 1.01e5; % ambient pressure [N/m2]
%% Dimensionless Parameters
s = ho.*sqrt(rhoo.*omega./mu); % shear wave number
k = omega.*ho./Co; % reduced frequency
sigma = sqrt(mu.*Cp./lambda); % square root of Prandtl number
g = ho./lx; % nawroness of the gap
gamma = Cp/Cv; % ratio of specific heats
a = ly/lx; % aspect ratio of the panel
kx = omega*lx/Co; % normalised wave number along x-axis
ky = omega*ly/Co; % normalised wave number along y-axis
Bs =(tanh(s.*sqrt(i))./(s.*sqrt(i)))-1;
Bssigma =(tanh(s*sigma.*sqrt(i))./(s*sigma.*sqrt(i)))-1;
nssigma = (1+((gamma-1)/gamma).*Bssigma).^(-1);
Gamma = sqrt(gamma/(nssigma*Bs));
Ceffs = Co.*sqrt(nssigma.*Bs/gamma) % effective speed sound [m/s]
syms x y q
D = sqrt(((q*pi/(2*a))^2) - (kx*Gamma)^2);
SUMp=0;
a=1:2:9;
for jj=1:length(a)
p = (2*nssigma*Gamma^2*kx*ky*h/pi).*symsum((((-1)^((q-1)/2)/(q*(D)^2)))*((cosh(D*x/kx)/cosh(D))-1)*cos(q*pi*y/(2*ky)),q,a(jj),a(jj));
SUMp=SUMp+p;
end
Antworten (1)
Walter Roberson
am 24 Mär. 2023
Pi = sym(pi);
syms D x y kh kx ky
syms q Q
q = 2*Q - 1;
expression = (((-1)^((q-1)/2)/(q*(D)^2)))*((cosh(D*x/kx)/cosh(D))-1)*cos(q*Pi*y/(2*ky));
symsum(expression,Q,1,5)
You might notice that the result is the same as if you had created the individual terms for odd q, and added the terms together. Which you could also do by taking the expression and subs() the q values in and sum() the result -- which is likely to be more efficient than forcing symsum() to analyze to see if it can find an expression and then ending up just adding the terms.
Can symsum() happen to find the infinite sum in this case? Let us test:
symsum(expression,Q,1,inf)
Looks like Yes, at least under certain conditions.
4 Kommentare
Walter Roberson
am 27 Mär. 2023
Your P includes the unresolved variable q
In your code version at https://www.mathworks.com/matlabcentral/answers/1934699-symsum-function-with-odd-number-and-infinity-upper-limit#comment_2675564 you had
syms x y q Q
D = sqrt(((q*pi/(2*a))^2) - (kx*Gamma)^2);
q = 2*Q-1;
Notice that uses q in D before you assign into q. Those two lines need to be reversed
syms x y q Q
q = 2*Q-1;
D = sqrt(((q*pi/(2*a))^2) - (kx*Gamma)^2);
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!