Using MATLAB as a calculator. Matlab Syntax

 As an example of a simple interactive calculation, just type the expression you want to

evaluate. Let’s start at the very beginning. For example, let’s suppose you want to calculate
the expression, 1 + 2 × 3. You type it at the prompt command (>>) as follows,
>> 1+2*3
ans =
7
You will have noticed that if you do not specify an output variable, MATLAB uses a
default variable ans, short for answer, to store the results of the current calculation. Note
that the variable ans is created (or overwritten, if it is already existed). To avoid this, you
may assign a value to a variable or output argument name. For example,
>> x = 1+2*3
x =
7
will result in x being given the value 1 + 2 × 3 = 7. This variable name can always
be used to refer to the results of the previous computations. Therefore, computing 4x will
result in
>> 4*x
ans =
28.0000
Examples:
		      7/0		      % Divide by zero
sin(pi /2)	  % sine of angle 90o                    

Comments

Popular posts from this blog

Image compression in matlab with explaination

Data Types in Matlab

Face detection in Matlab with source code