0% found this document useful (0 votes)
13 views5 pages

Matlabe Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Matlabe Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

function createAcousticWaveGUI()

% Create the figure and components


fig = uifigure('Name', 'Full Acoustic Wave Visualization', 'Position', [100,
100, 1000, 800]);

% Labels and fields for input


lblA = uilabel(fig, 'Position', [10, 720, 120, 22], 'Text', 'Amplitude (A):');
fldA = uieditfield(fig, 'numeric', 'Position', [130, 720, 100, 22]);
lblc = uilabel(fig,'Position',[10, 580, 150, 22], 'Text','sound speed (c)
m/s:') ;
ddc = uidropdown(fig ,'position',[130, 580, 100, 22],...
'Items',{'Air: 330-340 m/s','Water: 1450 m/s','Soft Tissue: 1540 m/s',
'Bone:3300 m/s'},...
'ItemsData',[335,1450,1540,3300]);
% Add the fields for the period, speed of sound, and density here
lblT = uilabel(fig, 'Position', [10, 700, 120, 22], 'Text', 'Period (T):');
fldT = uieditfield(fig, 'numeric', 'Position', [130, 700, 100, 22]);
lblRho = uilabel(fig, 'Position', [10, 680, 120, 22], 'Text', 'Density
(rho):');
fldRho = uieditfield(fig, 'numeric', 'Position', [130, 680, 100, 22]);
% Configuration of the button for calculation and plot
btn = uibutton(fig, 'push', 'Text', 'Calculate and Plot', 'Position', [250,
690, 150, 30]);
function createAcousticWaveGUI()
% Create the figure and components
fig = uifigure('Name', 'Full Acoustic Wave Visualization', 'Position', [100,
100, 1000, 800]);

% Labels and fields for input


lblA = uilabel(fig, 'Position', [10, 720, 120, 22], 'Text', 'Amplitude (A):');
fldA = uieditfield(fig, 'numeric', 'Position', [130, 720, 100, 22]);
lblR = uilabel(fig, 'Position', [500, 700, 120, 22], 'Text', 'Angular
frequency(R):');
lblF = uilabel(fig, 'Position', [500, 720, 120, 22], 'Text', 'frequency
(hz):');
lblW = uilabel(fig, 'Position', [500, 740, 120, 22], 'Text', ' Wavelenght
(w):');
lblc = uilabel(fig,'Position',[10, 580, 150, 22], 'Text','sound speed (c)
m/s:') ;
ddc = uidropdown(fig ,'position',[130, 580, 100, 22],...
'Items',{'Air: 330-340 m/s','Water: 1450 m/s','Soft Tissue: 1540 m/s',
'Bone:3300 m/s'},...
'ItemsData',[335,1450,1540,3300]);
% Add the fields for the period, speed of sound, and density here
lblT = uilabel(fig, 'Position', [10, 700, 120, 22], 'Text', 'Period (T):');
fldT = uieditfield(fig, 'numeric', 'Position', [130, 700, 100, 22]);
lblRho = uilabel(fig, 'Position', [10, 680, 120, 22], 'Text', 'Density
(rho):');
fldRho = uieditfield(fig, 'numeric', 'Position', [130, 680, 100, 22]);
% Configuration of the button for calculation and plot
btn = uibutton(fig, 'push', 'Text', 'Calculate and Plot', 'Position', [250,
690, 150, 30]);
ax2 = uiaxes(fig, 'Position', [510, 420, 480, 200], 'XGrid', 'on', 'YGrid',
'on');
title(ax2, 'Pressure');
xlabel(ax2, 'Time (s)');
ylabel(ax2, 'Pressure');
ax3 = uiaxes(fig, 'Position', [10, 100, 480, 200], 'XGrid', 'on', 'YGrid',
'on');
title(ax2, ' vieiocity field');
xlabel(ax2, 'Time (s)');
ylabel(ax2, 'Pressure');
ax4 = uiaxes(fig, 'Position', [500,100 , 480, 200], 'XGrid', 'on',
'YGrid', 'on');
title(ax2, 'pressue field');
xlabel(ax2, 'lateral distance (mm)');
ylabel(ax2, 'Axial distance');
function createAcousticWaveGUI()

% Create the figure and components


fig = uifigure('Name', 'Full Acoustic Wave Visualization', 'Position',
[100, 100, 1000, 800]);

% Labels and fields for input


lblA = uilabel(fig, 'Position', [10, 720, 120, 22], 'Text', 'Amplitude
(A):');
fldA = uieditfield(fig, 'numeric', 'Position', [130, 720, 100, 22]);
lblR = uilabel(fig, 'Position', [500, 700, 120, 22], 'Text', 'Angular
frequency(R):');
lblF = uilabel(fig, 'Position', [500, 720, 120, 22], 'Text', 'frequency
(hz):');
lblW = uilabel(fig, 'Position', [500, 740, 120, 22], 'Text', ' Wavelenght
(w):');
lblc = uilabel(fig,'Position',[10, 760, 150, 22], 'Text','sound speed (c)
m/s:') ;
ddC = uidropdown(fig ,'position',[130, 760, 100, 22],...
'Items',{'Air: 330-340 m/s','Water: 1450 m/s','Soft Tissue: 1540 m/s',
'Bone:3300 m/s'},...
'ItemsData',[335,1450,1540,3300]);
% Add the fields for the period, speed of sound, and density here
lblT = uilabel(fig, 'Position', [10, 700, 120, 22], 'Text', 'Period
(T):');
fldT = uieditfield(fig, 'numeric', 'Position', [130, 700, 100, 22]);
lblRho = uilabel(fig, 'Position', [10, 680, 120, 22], 'Text', 'Density
(rho):');
fldRho = uieditfield(fig, 'numeric', 'Position', [130, 680, 100, 22]);
% Configuration of the button for calculation and plot
btn = uibutton(fig, 'push', 'Text', 'Calculate and Plot', 'Position',
[250, 620, 150, 30], ...
'ButtonPushedFcn', @(btn,event) plotWave(fldA.Value,
fldT.Value, ddC.Value, fldRho.Value));
% Axes pour le tracé du déplacement et de la vitesse
ax1 = uiaxes(fig, 'Position', [10, 300, 480, 200], 'XGrid', 'on',
'YGrid', 'on');.
title(ax1, 'Displacement and Velocity');
xlabel(ax1, 'Time (s)');
ylabel(ax1, 'Displacement / Velocity');
ax4 = uiaxes(fig, 'Position', [500 ,100 , 480, 200], 'XGrid', 'on',
'YGrid', 'on');
title(ax4, 'pressue field');
xlabel(ax4, 'lateral distance (mm)');
ylabel(ax4, 'Axial distance');
ax3 = uiaxes(fig, 'Position', [10, 100, 480, 200], 'XGrid', 'on',
'YGrid', 'on');
title(ax3, ' vieiocity field');
xlabel(ax3, 'Time (s)');
ylabel(ax3, 'Pressure');
ax2 = uiaxes(fig, 'Position', [500, 300, 480, 200], 'XGrid', 'on',
'YGrid', 'on');
title(ax2, 'Pressure');
xlabel(ax2, 'Time (s)');
ylabel(ax2, 'Pressure');
function plotWave(A, T, c, rho)
t = linspace(0, 4*T, 1000);
% Calculate frequency, angular frequency, and wavelength
f = 1 / T;
omega = 2 * pi * f;
lamda = c / f;
% Calculate displacement, velocity, and pressure
x = A * sin(omega * t);
v = A * omega * cos(omega * t);
P = rho * c * A * omega * cos(omega * t);
lblF.Text = sprintf('Frequency (hz)' , f);
lblR.Text = sprintf('Angular Frequency (R) rad/s', omega);
lblW.Text = sprintf('wavelengh (w)', lamda);

You might also like