% Integration by Trapezoidal method % This example shows how you can do numerical integration by Trapizoidal % method % The formula for this method is given as ... % $$ \int\limits_0^{\frac{2\pi}{\omega}}f(t)dt = \frac{h}{2}\left[f(a) + % 2\sum_{i = 0}^{i = K - 1}f(x) + f(b)\right]$ % % where a = lower limit of integration, b = upper limit of integration % % $h = \frac{a - b}{K}$, where K = no. intervals under consideration % Here the function is $ f(t) = \frac{1}{1+x^2} $ Here we are integrating % from 0 to 6, taking 6 % intervals in between. clc; clear all; a = 0; b = 6; K = 6; h = (b - a) / K; t = 0 : .0001 :6; f = inline('1./(1+t.^2)', 't') plot(t, f(t),'r','linewidth',2.5) hold; t1 = a : h : b; stem(t1, f(t1),'m','filled','linewidth',2.5) grid; out = 0; for i = 1 : K - 1 out = out + f(a+i*h); end result = (h / 2) * (f (a) + 2 * (out) + f(b))Thank You

## Monday, April 8, 2013

### Numerical Integraion Using Trapezoidal Rule.

The process of evaluating a definite integral from a set of tabulated values of integrand f(t) is called numerical integration. The following MATLAB code gives a generalized illustration of numerical integration using Trapezoidal rule. The algorithm for the same is given in the comments at the beginning of the program. Try it for your own function.

## Thursday, March 28, 2013

### Installing LaTeX in Windows

To get started with LaTeX, a wonderful document or presentation maker. Follow the steps below

1. Install MikTeX. Use this link. http://mirrors.ctan.org/systems/win32/miktex/setup/basic-miktex-2.8.3761.exe

2. Use this link. http://www.xm1math.net/texmaker/texmakerwin32_install.exe

Happy TeXing....

1. Install MikTeX. Use this link. http://mirrors.ctan.org/systems/win32/miktex/setup/basic-miktex-2.8.3761.exe

2. Use this link. http://www.xm1math.net/texmaker/texmakerwin32_install.exe

Happy TeXing....

## Wednesday, March 6, 2013

### LaTeX Symbols

The important feature of LaTeX is its symbol(Mathematical and Others) handling capability. Here is a list of all symbols that is possible with LaTeX.

Hope you make use of it.

1. symbols-a4.pdf

2. symbols-letter.pdf

Hope you make use of it.

1. symbols-a4.pdf

2. symbols-letter.pdf

## Monday, February 11, 2013

## Sunday, February 10, 2013

### Newton Raphson Method

Hello everybody...

The following is a sample program to understand finding solution of a non linear equation using Newton Raphson Method. This program is not a generalised one. But you can understand the basic idea of the method and how to implement it using MATLAB. For more information about this method please try this

Try it for different functions

Thank you...

The following is a sample program to understand finding solution of a non linear equation using Newton Raphson Method. This program is not a generalised one. But you can understand the basic idea of the method and how to implement it using MATLAB. For more information about this method please try this

% This programme is to find the solution of a non linear equation by Newton Raphson method. % This is not a generalized program clc; clear all; format long; syms x; e = 1e-5; % setting the tolerance value dx = e + 1; f = log(2-x) + x^2; % enter your function here; x = 7; % initially assumed value of x count = 0; % setting counter to know the no of iterations taken p = zeros(1,1); while (abs(dx) > e) % initialising the iteration and continue until the error is less than tolerance dx = eval(f/(diff(f))); % calculating dx, diff is used for finding the differentiation of the fuction x = x - dx % updating the value of x count = count + 1; % incrimenting the counter p(count) = x; drawnow(); plot(abs(p),'r','linewidth',3); grid; if (count > 300) fprintf('Error...! Solution not converging !!! \n'); % printing the error message break; end end % plot(abs(p)); if (count < 300) fprintf('The solution = '); %printing the result x fprintf('\nNumber of iteration taken = %d\n',count); end

Try it for different functions

Thank you...

## Wednesday, February 6, 2013

### Convolution of two functions

Enter the following code in to your MATLAB editor. You could see how the convolution of two function in calculated. Try the same for your functions.

clc; clear all; t = 0 : 0.05 : 4; x = inline ('(exp(-0.001*t)).*(t >= 0)','t'); h = inline ('(exp(-0.001*t).*(t >= 0)) + (exp(-3*t)).*(t>=0)','t'); dtau = 0.005; tau = -1:dtau:4; ti = 0; tvec = -0.25:0.1:3.75; y = NaN * zeros (1, length (tvec)); figure(1); for t= tvec ti = ti + 1; xh = x(t - tau) .* h(tau); y(ti) = sum (xh .* dtau); subplot(2,1,1), plot(tau, h(tau), 'k-', tau,x(t-tau),'k--',t,0,'ok'); axis([tau(1) tau(end) -0.25 3]); subplot(2,1,2), plot(tvec, y, 'k', tvec(ti), y(ti),'ok'); axis([tau(1) tau(end) -0.25 5]); drawnow; pause(0.1); end

## Monday, February 4, 2013

### Using Inline fuction

inline(expression, arg1, arg2 ...) constructs an inline function whose input arguments are specified by the stringsarg1, arg2, ... Multicharacter symbol names may be used. This you can get from the matlab help.

Now.... how we can use them. I will divide it into different cases

If you want to make the graph thicker use

Now.... how we can use them. I will divide it into different cases

- Function with one variable.

t = -4 : 0.01 : 4; f = inline('(exp(t)+1)', 't');This will define your function. Now if you want to plot it in the whole range of t, use

plot(t, f(t));This will give you the following output (* click on the image to zoom in)

If you want to make the graph thicker use

plot(t,f(t),'linewidth', 2);

Test it with different values in place of 2.

2. Plotting different functions on same base

If you want plot different function for different input values then try as follows

f = inline('(-1.5*t+1) .* ((t>-3)&(t<0)) + (3) .* (t == 0)+ (1.5*t+1) .* ((t>0)&(t<3))'); plot(t,f(t),'r','linewidth', 3); grid on;You will get the

Subscribe to:
Posts (Atom)