-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeoretical_value.m
36 lines (26 loc) · 1.11 KB
/
theoretical_value.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [theo_transmission_coefficients]=theoretical_value(numberOfPoints)
% Given values
rho1 = 1.21; % Density of the first medium (kg/m^3)
c1 = 341; % Speed of sound in the first medium (m/s)
rho2 = 48.4; % Density of the second medium (kg/m^3)
c2 = 341; % Speed of sound in the second medium (m/s)
L = 1; % Length of the second medium (meters)
% Frequency range (from 0 to 300 Hz)
frequencies = linspace(0, 34100/2 ,numberOfPoints); %Oversampling
% Initialize an array to store transmission coefficients
theo_transmission_coefficients = zeros(size(frequencies));
% Calculate acoustic impedances
z1 = rho1 * c1;
z2 = rho2 * c2;
% Loop over each frequency and calculate the transmission coefficient
for ii = 1:length(frequencies)
f = frequencies(ii);
% Calculate wave number in the second medium
k2 = 2 * pi * f / c2;
% Calculate the sine term
sin_term = sin(k2 * L).^2;
% Calculate the transmission coefficient
numerator = 4;
denominator = 4 + ((((z2 / z1) - (z1 / z2)).^2 ).* sin_term);
theo_transmission_coefficients(ii) = numerator ./ denominator;
end