Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

EXPERIMENT – 05

AIM: -
Write a MATLAB code for the propagation of Group Wave as function of Time.
% EXPERIMENT 5: To write matlab program to show propogation of wave group.
clear all
clc

A= 0.05;
w=2;
k=0.2;
dw=0.002;
dk=0.01;
z=-500:1:500;
for t=0:50
psi=2*A*cos(w.*t-k.*z).*cos(dw.*t-dk.*z);
plot(z,psi)
title(['group wave after time t=',num2str(t),'seconds'])
xlabel('z');
ylabel('wave group');
pause(0.1);
end
EXPERIMENT – 06
AIM: -
Write MATLAB program to find out the roots of a given using bisection method compare
results using inbuilt functions.
%EXPERIMENT 6: To find roots
clear all
clc
format long
f=[1 0 -4];
roots(f)

ans = 2×1

2.000000000000000
-2.000000000000000

%using bisection method


y= @(x)x^2-4;
xmin=-2.1;
xmax=2.1;
nstp=10000;
inc=(xmax - xmin)./nstp;
disp(['display in accuracy is ', num2str(inc)])

display in accuracy is 0.00042

for nstp=1:10000
if(y(xmin)*y(xmin+inc)<=0)
roots_bisect=(xmin+xmin+inc)/2
else
end
xmin=xmin+inc;
end

roots_bisect =

-1.999829999999979

roots_bisect =

1.999830000000352
EXPERIMENT – 07
AIM:

% TO WRITE MATLAB PROGRAM TO FIND OUT THE UNKNOWN COEFFICIENTS BY


% POILYNOMIAL FITTING.
clear all
clc

x=[1 2 3 4 5];
y=[3 4.8 7.4 8.9 11];
a=polyfit(x,y,1);
xi=linspace(1,8,50);
yi=polyval(a,xi);
plot(x,y,'o',xi,yi)
xlabel('x');
ylabel('y');
legend('experimental data points','fitted curve')

%pressure equation p=p0*exp(-t/tau);


t=[0 0.5 1 5 10 20];
p=[760 625 528 85 14 0.16];
pbar= log(p);
a=polyfit(t,pbar,1);
tau=-1/a(1);
p0= exp(a(2));
disp(['coefficient tau =', num2str(tau)]);

coefficient tau =2.3739

disp(['coefficient p0 =', num2str(p0)]);

coefficient p0 =781.1432

tnew =linspace(0,20,50);
pnew=p0.*exp(-tnew./tau);
plot(t,p,'o',tnew,pnew)
xlabel('time')
ylabel('pressure')
legend('experimental data points','fitted curve')

You might also like