>>a+b
ans = 8 7 8 6
>>a-b
ans = 6 1 -2 -8
>>3*a
ans = 21 12 9 -3
>>3.*a
ans = 21 12 9 -3
>>a.*b
ans = 7 12 15 -7
>>b.*a
ans = 7 12 15 -7
>>3.^a
ans = 1.0e+003*
2.1870 0.0810 0.0270 0.0003
>>a.^b
ans = 7 64 243 -1
>>b.^a
ans = 1.0000 81.0000 125.0000 0.1429
Try also the following example on your own.
Example 14.1 This example will show how the density of standard air changes with temperature. It also makes
(Revisited) use of MATLAB’s element by element operation. The density of standard air is a function of
temperature and may be approximated using the ideal gas law according to
where
Pstandard atmospheric pressure (101.3 kPa)
Rgas constant and its value for air is 286.9
Tair temperature in Kelvin (K)
a
J
kg#K
b
r
P
RT
TABLE 15.4 MATLAB’s Element by Element Operations
Equivalent Element by
Arithmatic Element Symbol for
Operation Operations the Operation
Addition
Subtraction
Multiplication * .*
Division /. /
Raised to a power ^ .^
468 Chapter 15 MATLAB
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
圀圀圀⸀夀䄀娀䐀䄀一倀刀䔀匀匀⸀䌀伀䴀圀圀圀⸀夀䄀娀䐀䄀一倀刀䔀匀匀⸀䌀伀䴀