Wednesday, August 25, 2010

How to do fibonnaci series using matlab

FIBONNACI SERIES:


Let  us use matlab to compute the FIBONNACI SERIES 1, 1, 2, 3, 5, 8, 13, 21,.........


We know the first two elements starts with 1,1 & each next element  is sum of the two previous elements.


We are going to  use FOR loop for finding the fibonnaci series.


SYNTAX for ‘FOR’ LOOP:
             
    for counter=legal list of values
        ......statement to be executed repeatedly with in this loop
    end


MATLAB CODING FOR FINDING FIBONNACI SERIES:


  f(1)=1;


  f(2)=1;


  for i=3:11


    f(i)=f(i-1)+f(i-2);


  end


  f(1:11)
 
ans =


     1     1     2     3     5     8    13    21    34    55    89

Tuesday, August 17, 2010

Reading and displaying two input image

If we want to show two images in the screen at the same time we have the syntax.

For eg:If another image is displayed using imshow,Matlab replaces the image in the screen with the new image.It displays only the second image.

To keep the first image & second image in the screen we use the function"figure" .

SYNTAX  as  imshow(first image),figure,imshow(second image)
It displays both the images.

We get the first input image called 'greatwall.jpg' & second image called 'FLOWERS.jpg'.It will be displayed at the same time.

MATLAB CODING:

A=imread('greatwall.jpg');
c=imread('FLOWERS.jpg');
imshow(A),figure, imshow(c);


Saturday, August 14, 2010

HOW TO RESIZE THE IMAGE

 Warning occurs in matlab like"image is too big to fit on screen".For that we should resize our image.We have to reduce our size of the image.

SYNTAX for resizing the image:

       a=imread('filename.jpg');

       b=imresize(a,[mrows n columns]);


MATLAB CODING TO RESIZE THE IMAGE:

>>a=imread('greatwall.jpg');
>>imshow(a)
>> b=imresize(a,[400 300]);
>> imshow(b)


 ORIGINAL IMAGE:


RESIZED IMAGE:

HOW TO USE 'FOR'LOOP

 SYNTAX:

       for counter=legal list of values

          statement to be executed repeatedly with in this loop

      end

Example:

    >> sum=0;
    >> for i=1:10
         sum=sum+i;
    end
    >> sum

    sum =

        55

Tuesday, August 3, 2010

Reading and displaying an input image

TO READ AN INPUT IMAGE:

       First,browse to the image folder on the top left window named "Current Directory".
            
                   • To read a graphics file format image use" imread".

                   • The imread function reads image data into MATLAB arrays from graphics files in various    standard formats, such as gif, tiff , jpeg, png etc..

imread:
    imread - used to read image
    imread (‘filename’)

      File name is the name of the image file you wish to read. Put the file name within single quotes ‘ ‘).

 Example:
                       imread('image.jpg')


1.Get the variable called image
2.’imread’ is one of the command to read the input image
3.Finally ‘imshow’ is the command to view the image.

To show the image:
             imshow(variable)


**********coding**********
image=imread('image1.jpg');
imshow(image);

The image opens as below,

Starting Matlab and working basics

How to work in  matlab?

You have to write codings on the command window with the prompt: >>
You can view your codings in command history.