|
|
| File Information |
| Description |
SWAP(A,B) puts the contents of variable A into variable B and vice versa. You can use either function syntax 'swap(A,B)' or command syntax 'swap A B'.
Example:
A = 1:4 ; B = 'Hello' ;
swap(A,B) ;
A % -> Hello
B % -> 1 2 3 4
swap A B ; % and back again ...
SWAP(A,B) is a convenient easy short-cut for other (series of) commands that have the same effect,e.g.,
temp=A ; A=B ; B=temp ; clear temp ;
[B,A] = deal(A,B) ;
The advantage over these two methods is that using SWAP one does not have to declare intermediate variables or worry about output. |
| MATLAB release |
MATLAB 6.5 (R13)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (3) |
| 12 Sep 2006 |
Carlos Lopez
|
|
|
| 13 Sep 2006 |
Jos vdG
|
|
|
| 13 Sep 2006 |
urs (us) schwarz
|
|
|
| Updates |
| 13 Sep 2006 |
1. Use <deal> to swap (insight from US)
2. Added command syntax functionality (suggested by DH)
3. Modified help section |
|
Contact us at files@mathworks.com