Matlab entry basics note1-assignment and decimals

Matlab Chapter I

Assignment
If you enter in Matlab x + 6 = 90you will get error;
you have to do is to have x aside: x = 90 - 6so, 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 longchange it to 16 digits by using, or format banktake 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 ratfind 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:

piRepresents the pi;
exp(a)represents the natural logarithm;
sqrttakes the square;
log(a)finds the natural logarithm;
log10(a)finds the logarithm based on 10
cos;, acosrepresents the trigonometric function and the inverse trigonometric function;

Guess you like

Origin blog.csdn.net/RiptidePzh/article/details/112976961