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 ...

Get Electromagnetic Field Theory now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.