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 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)])


No comments:

Post a Comment