Professional Documents
Culture Documents
matlab_file.docx
matlab_file.docx
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
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:
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')
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')