Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MATLAB
- 1)Bessel fist kind
- X = 0:0.1:20;
- J = zeros(5,201);
- for i=0:4
- J(i+1,:) = besselj(i,X);
- end
- figure('Position',[0 0 1024 768])
- plot(X,J,'LineWidth',1.5)
- axis([0 20 -.5 1])
- grid on;
- legend('J_0','J_1','J_2','J_3','J_4','Location','Best')
- title('Bessel Functions of the First Kind for n = 0,1,2,3,4')
- xlabel('X')
- ylabel('J_n(X)')
- 2)Bessel second kind
- X = 0:0.1:20;
- Y = zeros(5,201);
- for i=0:4
- Y(i+1,:) = bessely(i,X);
- end
- figure('Position',[0 0 1024 768])
- plot(X,Y,'LineWidth',1.5)
- axis([-0.1 20.2 -2 0.6])
- grid on;
- legend('Y_0','Y_1','Y_2','Y_3','Y_4','Location','Best')
- title('Bessel Functions of the Second Kind for n = 0,1,2,3,4')
- xlabel('X')
- ylabel('Y_n(X)')
- 3)Fourier Series
- clear all
- clc
- syms x k L U n
- f = input('Enter the function: ');
- L = input('Enter the lower limit: ');
- U = input('Enter the upper limit: ');
- l = (U-L)/2;
- n = input('Enter the number of terms required: ');
- ak = @(f,x,k) int(f*cos(k*pi*x/l)/l,x,L,U);
- bk = @(f,x,k) int(f*sin(k*pi*x/l)/l,x,L,U);
- fs = @(f,x,n) ak(f,x,0)/2 + ...
- symsum(ak(f,x,k)*cos(k*pi*x/l) + bk(f,x,k)*sin(k*pi*x/l),k,1,n);
- pretty(fs(f,x,n))
- fst = ak(f,x,0)/2;
- for i=1:n
- fst = fst + ak(f,x,i)*cos(i*pi*x/l) + bk(f,x,i)*sin(i*pi*x/l);
- disp(['Harmonics upto:', num2str(i)]);
- disp(fst);
- h=ezplot(f,[L U]);
- set(h,'LineWidth',2)
- hold on;
- h = ezplot(fst,[L U]);
- set(h,'LineStyle','-','Color',[i/n 1/i 1/n],'LineWidth',2);
- title(['Partial sums up to n=',num2str(i)])
- end
- 4)Harmonic analysis
- clear all
- clc
- syms t
- n = input('Enter the number of data points n : ');
- x_0 = input('Enter the starting value of x : ');
- s = input('Enter the length of the spacing between successive values of x :
- ');
- count = input('Enter 0 if the unit of x is degrees, otherwise enter a nonzero
- number: ');
- y = input('Enter the y values (as a row vector): ');
- n1 = input('Enter the number of harmonic of the series n1 : ');
- x = x_0 + (0:n-1)*s;
- if(count == 0)
- x=x*pi/180;
- s=s*pi/180;
- end
- l=0.5*(x(n)+s-x(1)); % l=pi if it is degree
- a_0 = (2/n)*sum(y);
- for i=1:n1
- yc=y.*cos(i*pi*x/l);
- ys=y.*sin(i*pi*x/l);
- a(i)=(2/n)*sum(yc);
- b(i)=(2/n)*sum(ys);
- end
- F_s=a_0/2;
- figure('Position',[1 1 1024 768])
- for i=1:n1
- subplot(n1,1,i)
- plot(x,y,'r*');
- hold on
- F_s = F_s+a(i).*cos(i*pi*t/l)+b(i).*sin(i*pi*t/l);
- ezplot(F_s, [x(1) x(n)])
- title(['Harmonics up to: ', num2str(i)])
- end
- disp('Fourier series : ')
- vpa(F_s,4)
- 5)second order difference equation with constant coeff
- clear all
- clc
- syms n k1 k2
- a = input('Enter the coefficient of y(n+2): ');
- b = input('Enter the coefficient of y(n+1): ');
- c = input('Enter the coefficient of y(n): ');
- g = input('Enter the non-homogeneous part: ');
- r = roots([a b c]);
- if imag(r)~=0
- rho = sqrt(real(r(1))^2 + imag(r(1))^2);
- theta = atan(abs(imag(r(1)))/real(r(1)));
- y1 = (rho^n)*cos(n*theta);
- y2 = (rho^n)*sin(n*theta);
- elseif r(1)==r(2)
- y1 = r(1)^n;
- y2 = n*r(1)^n;
- else
- y1 = r(1)^n;
- y2 = r(2)^n;
- end
- Co = det([y1, y2;subs(y1,n,n+1), subs(y2,n,n+1)]); %Casoratian of the solutions
- y_c = k1*y1 + k2*y2;
- disp('Complementary Solution is: ');
- disp(y_c);
- if(g ~= 0)
- y11 = subs(y1,n,n+1);
- y21 = subs(y2,n,n+1);
- 36
- Co1 = subs(Co,n,n+1);
- u1 = simplify(symsum(-g*y21/Co1,n,0,n-1));
- u2 = simplify(symsum(g*y11/Co1,n,0,n-1));
- y_p = simplify(u1*y1+u2*y2);
- y = y_c + y_p;
- else
- y = y_c;
- end
- check = input('If the given problem has initial conditions then enter 1 else enter 0: ');
- if (check == 1)
- yval1 = input('Enter the initial condition at n = 0: ');
- yval2 = input('Enter the initial condition at n = 1: ');
- cond1 = strcat(char(subs(y,n,0)),'=',num2str(yval1));
- cond2 = strcat(char(subs(y,n,1)),'=',num2str(yval2));
- [k1,k2] = solve(cond1,cond2);
- y = subs(y);
- end
- disp('Complete Solution is: ')
- disp(collect(collect(y,y1),y2))
- if(check ~= 0)
- nrange = linspace(0,10,40);
- Y = subs(y,n,nrange);
- stem(nrange,Y);
- set(gca,'XTick',linspace(0,10,11))
- xlabel('n');
- ylabel('y(n)');
- end
- 6)SOLUTION OF FIRST AND SECOND ORDER DIFFERENCE EQUATIONS USING Z – TRANSFORM
- clc
- clear all
- syms n z Yz g
- yn = sym('y(n)');
- yn1 = sym('y(n+1)');
- yn2 = sym('y(n+2)');
- a = input('The Coefficient of y(n+2) = ');
- b = input('The Coefficient of y(n+1) = ');
- c = input('The Coefficient of y(n) = ');
- nh = input('The Non Homogeneous part ');
- eq = a*yn2 + b*yn1 + c*yn - nh;
- Zeq = ztrans(eq, n, z);
- if (a==0)
- d = input('The initial value at 0 is ');
- Zeq = subs(Zeq,{'ztrans(y(n), n, z)', 'y(0)'}, {Yz, d});
- else
- d = input('The initial value at 0 is ');
- e = input('The initial value at 1 is ');
- Zeq = subs(Zeq,{'ztrans(y(n), n, z)', 'y(0)', 'y(1)'}, {Yz, d, e});
- end
- eq = collect(Zeq, Yz);
- Y = solve(eq, Yz);
- Y = iztrans(Y, z, n);
- Y = simple(Y)
- m = 0:20;
- y = double(subs(Y,n,m));
- stem(y)
- title('Difference equation');
- xlabel('n'); ylabel('y(n)');
- forms
- <html>
- <body>
- <table>
- <tr>
- <td>Name:</td>
- <td><input type="text" name="name" value="" size="25"></td>
- </tr>
- <tr>
- <td>Address:</td>
- <td><input type="text" name="address" value="" size="25"></td>
- </tr>
- <tr>
- <td>City:</td>
- <td><input type="text" name="city" value="" size="25"></td>
- </tr>
- <tr>
- <td>State:</td>
- <td><input type="text" name="state" value="" size="25"></td>
- </tr>
- <tr>
- <td>Zip:</td>
- <td><input type="text" name="zip" value="" size="25"></td>
- </tr>
- <tr>
- <td>Magazine:</td>
- <td><select name = "newspaper">
- <option value="1" selected = "selected">The Times Of India</option>
- <option value="2" selected = "selected">Hindustan Times</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Subscription:</td>
- <td><input type ="radio" name="1yr" value="1" checked ="checked">1 year
- <input type ="radio" name="1yr" value="1" >2 year</td>
- </tr>
- </table>
- </br>
- Additional Comments: </br>
- <textarea name="add com" rows="10" cols="30">
- </textarea>
- </br>
- <input type="submit" name="submitbtn" value ="submit"/>
- </body>
- </html>
- frames
- <!DOCTYPE html>
- <html>
- <title>Frames</title>
- <frameset rows="20%,80%">
- <frame name="top" src="/html/top_frame.htm"/>
- <frameset cols="20%,80%">
- <frame name="left" src="file:///tmp/guest-JFl73a/Desktop/a.html"/>
- <frame name="right" />
- </frameset>
- </frameset>
- </html>
- link to frame
- <!DOCTYPE html>
- <html>
- <title>group</title>
- <body>
- <a href="http://www.tutorialspoint.com" target="right">click here!</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment