Matlab Chapter I
Assignment
If you enter in Matlab x + 6 = 90
you will get error;
you have to do is to have x aside: x = 90 - 6
so, Matlab will give you output the correct answer x = 84
therefore, the assignment operator must give you the right to use a variable variable assignment, Otherwise, an error will occur.
The default number of matlab to control the number of decimal places is 4 digits, we can format long
change it to 16 digits by using, or format bank
take the decimal place to the last two digits ;
>> format long
>> x = 3 + 11/16 +2^1.2
x =
5.98489670999407
>> format short
>> x = 3 + 11/16 +2^1.2
x =
5.9849
- We can
format rat
find the ratio that is closest to the result by typing :
>>format rat
>>7.2*3.1
ans =
558/25
The basic mathematical definition
matlab contains commonly used mathematical quantities such as pi and e:
pi
Represents the pi;
exp(a)
represents the natural logarithm;
sqrt
takes the square;
log(a)
finds the natural logarithm;
log10(a)
finds the logarithm based on 10
cos
;,acos
represents the trigonometric function and the inverse trigonometric function;