正在加载图片...
1 Basic Operations 3 divis ion,and MATLAB always returns the correct result.If such is not the case,ther is certainly something wrong with what you typed.For example,you can try the following operations(type the operation after the>>prompt followed by Enter): MATLAB answer Meaning of the operation 35*12 ans=420 Multiplication 2/45 ans=0.0444 Division -1 an■3 Subtraction 23 ans=8 Exponentiation Note that to type numbers such as the Avogadro'snumber3you can eithe sent the numb numbe insc ,ype6.023e2 ntissa and exponent must be sepa- rated by the letter e (or E): >6.023*10^23 <ENTER> >6.023e23 <ENTER> an26.0230e+023 an 6.0230e+023 Such numbers are also defined to be floating point. MATLAB warns you in the case of in invalid operation or"unexpected"results What do you think MATLAB will show us if we type 12/0 or 0/0?Let's try it: To TYPE after prompt>> followed by Enter MATLAB answer Meaning of the answer 12/0 ans=Inf You should not divide by zero.but if you do.the result is Infinity /0 ns =NaN Unable to find the answer.so the result is nan=not a number 11 22211+ If you want to perform this operation,you must complete the Error:Expression expression with another term or statement is incorrect As you can see.MATLAB is unable to "stay quiet."It quickly answers your commands by displaying something in the command window.In the previous cases the answer was a special value such as Inf (Infinity)or NaN (Not a Number).You can use these special values on their own,typing.for example: >>12/Inf <ENTER> ans 0 1 Basic Operations 3 You can perform other arithmetic operations, such as multiplication, subtraction, and division, and MATLAB always returns the correct result. If such is not the case, there is certainly something wrong with what you typed. For example, you can try the following operations (type the operation after the >> prompt followed by Enter): To TYPE after prompt >> followed by Enter MATLAB answer Meaning of the operation 35*12 ans= 420 Multiplication 2/45 ans= 0.0444 Division 4−1 ans= 3 Subtraction 2^3 ans= 8 Exponentiation Note that to type numbers such as the Avogadro’s number 6.023 × 10 23, you can either write the expression 6.023*10^23 or you can represent the number in scien￾tifi c notation. To enter Avogadro’s number in scientifi c format, type 6.023e23, where 6.023 is the mantissa and 23 is the exponent. Mantissa and exponent must be sepa￾rated by the letter e (or E): >> 6.023*10^23 <ENTER> ans = 6.0230e+023 >> 6.023e23 <ENTER> ans = 6.0230e+023 Such numbers are also defi ned to be fl oating point. MATLAB warns you in the case of in invalid operation or “unexpected” results. What do you think MATLAB will show us if we type 12/0 or 0/0? Let’s try it: To TYPE after prompt >> followed by Enter MATLAB answer Meaning of the answer 12/0 ans= Inf You should not divide by zero, but if you do, the result is Infi nity 0/0 ans= NaN Unable to fi nd the answer, so the result is NaN = Not a Number 11+ ??? 11+ | Error: Expression or statement is incomplete or incorrect If you want to perform this operation, you must complete the expression with another term As you can see, MATLAB is unable to “stay quiet.” It quickly answers your commands by displaying something in the command window. In the previous cases, the answer was a special value such as Inf (Infi nity) or NaN (Not a Number) . You can use these special values on their own, typing, for example: >> 12/Inf <ENTER> ans = 0
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有