How to plot absorption of sound waves in seawater and boric acid?

2 ビュー (過去 30 日間)
Junaid Qadir
Junaid Qadir 2019 年 10 月 6 日
コメント済み: Junaid Qadir 2019 年 10 月 8 日
Please provide a Matlab code for the figure below.
a.png

採用された回答

Stephan
Stephan 2019 年 10 月 6 日
% Produce some data
x = logspace(-1,2);
y1 = exp(x);
y2 = (exp(x)./exp(y1));
% Plot lo double log-scale
loglog(x,y1,'--k','LineWidth',2)
hold on
loglog(x,y2,'-k','LineWidth',2)
hold off
% Change look
a = gca;
grid on
xlabel('Frquency - kHz')
ylabel('Attenuation - dB/km')
legend({'Saltwater', 'MgSO_{4}'}, 'Interpreter', 'tex', 'Location', 'southeast')
a.GridLineStyle = '--';
a.MinorGridLineStyle = '--';
a.GridColor = 'k';
a.MinorGridColor = 'k';
a.GridAlpha = 1;
a.MinorGridAlpha = 1;
  6 件のコメント
Junaid Qadir
Junaid Qadir 2019 年 10 月 6 日
Thank you so much for your kind help.
Junaid Qadir
Junaid Qadir 2019 年 10 月 8 日
Dear Stephan, please see code below and kindly let me know where is the problem occuring? Why the plot does not draw? I think there is some missing of ''for loop''.
%************* Junaid Qadir *************%
%************* MPhil Electronics *************%
%************* Department of Electronics *************%
%************* Quaid-i-Azam University Islamabad,45320, Pakistan *************%
% %************* Email: jndqadar@gmail.com , Instagram: @junaid_qadar, Facebook: https://web.facebook.com/junaid.qadar*************%
%%%%%%%%%%%%% BORIC ACID + Magnesium sulphate+ Pure water
clear all
close all
clc
f= 30; % kHz
S= 35; % salinity
T=10; % temmperature in degree centi grad
pH= 7.8;
theta= 273+T;
D= 500; % Depth in meter
c = 1449 + 4.591 *T - 5.304 * 10^(-2)*T^(2) + 2.374 * 10^ (-4) * T^(3) + 1.34*(S - 35) ...
+ 1.63 * 10^(-2) * D + 1.675 * 10^(-7)* D + 1.025* 10^(-2)* T*(S - 35) - 7.139* 10^(-3)*T*D^3; % Sound Speed in water = 1500 m/s
p1= 1; % pressur 1
p2= 1-1.37* 10^(-4) *D +6.2*10^(-9)* D^2; % pressure 2
p3= 1-3.83*10^(-5) * D+4.9*10^(-10) *D^2; % Pressur 3
f1= 0.78* sqrt(S/35)*10^(T/26); % frequency 1
f2= 8.17*10^(8-1990/theta); %fruency 2
A1= 8.86/c*10^(0.78*pH-5); % Absorption
A2= 21.44* S/c*(1+0.025*T); % Absorption
A3= 3.964*10^(-4)- 1.146* 10^(-5)*T +1.45*10^(-7)*T^2-6.5*10^(-10)*T^3; % Absorption
Boric_acid= A1*p1*f1*f/ f1^2*f^2; % Formula for Boric acid
Magnesium_sulphate= A2*p2*f2*f^2/ f2^2+f^2; % Formula for Magnesium sulphate
Pure_water= A3*p3*f^2; % pure water
Total= Boric_acid+ Magnesium_sulphate + Pure_water; % Total Absorption
% Plot to double log-scale
loglog(Boric_acid,f,'--r','LineWidth',2)
hold on
loglog(Magnesium_sulphate,f,'-*k','LineWidth',2)
hold on
loglog(Pure_water,f,'-.*g','LineWidth',2)
hold on
loglog( Total,f,'--hb','LineWidth',2)
hold off
% Change look
a = gca;
grid on
xlabel('Frquency - kHz')
ylabel('Attenuation - dB/km')
legend({'Boric acid', 'MgSO_{4}', 'Pure water ', 'Total absorption'}, 'Interpreter', 'tex', 'Location', 'southeast')
a.GridLineStyle = '--';
a.MinorGridLineStyle = '--';
a.GridColor = 'k';
a.MinorGridColor = 'k';
a.GridAlpha = 1;
a.MinorGridAlpha = 1;

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by