Some Great Thoughts

"Go ahead and do your best" | "It is the simple things in life that build brilliance in creativity..simplicity cannot be taught, it is inborn..do not tamper with it" | "All men dream but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity; but the dreamers of the day are dangerous men, for they may act their dream with open eyes to make it possible" | "इच्छा हमेशा योग्यता को हरा देती है" | "If you think you can do a thing or think you can't do a thing, you're right. -Henry Ford" | "Failure is success if we learn from it. -Malcolm S. Forbes" | "The future belongs to those who believe in the beauty of their dreams. -Eleanor Roosevelt" | "The great men and women of history are remembered, not because they never made mistakes or never failed, but because they didn't let their failures stop them. They kept on until they succeeded" | "असफलता हमें सिखाती है कि सफलता का प्रयत्न पूरे मन से नहीं किया गया"

Friday, December 30, 2011

Programming in MATLAB for Beginners-5

Now move a step ahead towards high level programming in MATLAB:

Is it possible to make large programs & store our codeings on MATLAB?????
Answer is YES........
How???????
with the help of editor
Editors: editors are use for store the cods or set of instructions. we can run our code or program stored in editor any time. editor create a M-File with the extension " .m ".
to open editor just type " edit " on your command window, you will get a new window. 
There are two types of M-File:
  1. Script Files
  2. Function File
Script File: Script files are set of codes & instructions. we can say scripts are simplest kind of M-File. a script file contain a whole as well as a part of any program. we can run any program directly from editor. the output will shown on command window.
to call any script file just type the name of file on command window.

Function File: MATLAB has many inbuilt functions like sin, cos etc. but some time we need a function which is not inbuilt in MATLAB. to create such functions we also use editors. once we create a function, we can call it any time in our program.

always remember the name of any M-File must not be same as any inbuilt function or command in MATLAB.

Friday, December 23, 2011

Programming in MATLAB for Beginners-4

Let's take some examples:


Create a vector of the even whole numbers between 45 & 98.:

to perform this operation use " : " operator
X=[46:2:98];

Compute the length of hypotenuse of a right triangle if the length of two other sides are given:
We can calculate the hypotenuse of a right triangle using this formula C2=A2+B2
A=input('enter the value of base ');
B=input('enter the value of perpendicular side ');
C=sqrt(A^2+B^2);
['length of hypotenuse']
disp(C)

Concatenation of two matrices:
Suppose we have two matrices A & B
we can conctenat both matrices as follow-
C=[A B];
or
C=[A ; B];

How to convert a number into a string:
use num2str(A) to perform above operation
consider previous example of right triangle once again
A=input('enter the value of base ');
B=input('enter the value of perpendicular side ');
C=sqrt(A^2+B^2);
disp(['length of hypotenuse ',num2str(C)])


Thursday, December 22, 2011

Response of a 2nd order system

A simplest way of getting response of a second order system......

Program:
% transfar function & response of a 2nd order system
% zeta is tha damping factor
% wn is natural frequency
zeta=input('enter zeta ');
wn=input('enter wn in rad/sec ');
num=[wn^2];
den=[1 2*zeta*wn wn^2];
G=tf(num,den)                  %% get transfar function
subplot(2,2,1),step(G)      %% step response response of system
subplot(2,2,2),impulse(G)  %% impulse response of system
subplot(2,2,3),bode(G)     %% bode plot of system
subplot(2,2,4),nyquist(G)  %% nyquist plot of system

Output:

Thursday, December 8, 2011

Sorry...

friends right now I can't update new post due to my end semester examination.....you can get new updates after 29th Dec,2011 .....so sorry.....

Monday, September 12, 2011

Programming in MATLAB for Beginners-3

Multiplication of two Matrices:-
There are two type of multiplication that we can performed in MATLAB
1.Multiplication of two Matrices in normal way:
   A=B*C;
2.Multiplication of each elements of first matrix with corresponding elements of second matrix:
A=B.*C;
it use " . " before " * ". for thsi operation no. of elements should be same in both matices.

Similarly we can perform Division operation.

Some Mathematical Operations & Their Instructions:-


Addition            A=B+C;
Subtraction        A=B-C;
Multiplication     A=B*C;  or  A=B.*C;
Division             A=B/C; or A=B./C; or A=B\C; or A=B.\C;
                         (A=B\C=C/B)
Transpose         B=A';


Power              B=A.^C; or A.^2  (this operation always performed with " . ").
Sum of All Elements of A Matrix
X=sum(A);
Diagonal elements of any matrix
Y=diag(A);
max no. in any matrix
M=max(A);
shortest no. in any matrix
S=short(A);
Average        A=avg(B);


Trigonometric Operations
Sine               A=sin(B);
Cosine           A=cos(B);
Sine Inverse   A=asine(B);

Sunday, September 11, 2011

Programming in MATLAB for Beginners-2

How to create a Matrix:-
enter all elements separated by space or coma & inclosed with [ ].
A=[1 2 3 4 5];
or
A=[1,2,3,4,5];
for coulmn matrix elements separated by semi colon ( ; )
A=[1;2;3;4;5]

A=[N:M]; create a row matrix with starting number N & last element M with the difference of "1".
A=[M:D:M]; create a row matrix with starting number N & last element M with the difference of "D".
A=zeros(R,C); create a matrix of "R" Row & "C" Column with all elements Zero.
A=ones(R,C); create a matrix of "R" Row & "C" Column with all elements One.
A=rand(R,C); create a matrix of "R" Row & "C" Column with Random Elements b/w 0 & 1 .
A=eye(R,C); create a Identity Matrix of "R" Row & "C" Column.


How to use editor:-
just type edit on comaand window & press enter.
       you get a new window in which you can write your program or function.
       save this file with .m extentation.


 How to I/P any variable at run time:-
use input(' ') command for it in editor at the time of writing program.
A=input('enter the value of A');



Programming in MATLAB for Beginners-1

Programming in MATLAB is simpler then any other programming language.
Here you can see the MATLAB window which contain "Directory, Command Window, Workspace & Command History".
We use Command Window to write any program or commands. Command windo also show output of any program or any instuction.
We can check our variables in Workspace & we also get our previous commands in Command History.
Here is some Basic Programs for beginners like Addition or other mathematical operations.

 Program of Addition of Two or More Numbers:-

>> %input first number
>> a=5;
>> %input second number
>> b=9;
>> %addition
>> c=a+b

c =

    14
Or



>> %input first number
>> a=5;
>> %input second number
>> b=9;
>> %addition
>> c=a+b;
>> %type c and press enter
>> c

c =

    14

Or

>> %input first number
>> a=5;
>> %input second number
>> b=9;
>> %addition
>> c=a+b;
>> %to display result use 'disp'
>>disp(c)
    14

Similarly we can perform subtraction of two numbers.


Starting with MATLAB

What is MATLAB?

  • High-level language for technical computing
  • Development environment for managing code, files, and data
  • Interactive tools for iterative exploration, design, and problem solving
  • Tools for building custom graphical user interfaces
  • MATLAB is a powerful tool for engineers to perform any task in there professional life.
  • Programming in MATLAB is simpler then C, C++ or any other programming language.
  • We can perform many mathematical & technical operation on MATLAB


for more detail you can alos visit MATLAB