## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

## Appendix A

#### Program 1: Addition of Two Vectors

```clc
clear all
disp(‘---------------------------’);
disp(‘     ADDITION OF TWO VECTORS P & Q (P + Q)            ’);
disp(‘---------------------------’);
disp(‘Enter values for vector P ex [1 -1 0]’);
P = input(‘Enter P:’);
disp(‘Enter values for vector Q ex [2 3 -1]’);
Q = input(‘Enter Q:’);
disp(‘Sum of two vectors P and Q is’);
C = P + Q               % Sum of two vectors
C_mag = sqrt(dot(C,C)); % magnitude of vector C
fprintf(‘Magnitude of the sum of two vectors is %f\n’,C_mag);
```

#### Simulation Results of Program 1 Implementation (Addition of Two Vectors)

`------------------------------------ ADDITION OF TWO VECTORS P & Q (P + Q) ------------------------------------ Enter values for vector P ex [1 -1 0] Enter P:[0 2 4] Enter values ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required