Here is a bit of Matlab code that adds two 2Dimensional vect

Here is a bit of Matlab code that adds two 2-Dimensional vectors together by getting the components and summing the components. Use the blank lines to create a loop using this code, so that any number of vectors can be added, as the code user desires. %These first two line merely initialize X and Y so that no \"old\" values contaminate the calculations, and % so that X and Y can be used in calculations. They do not need to be in the loop. X = 0; Y = 0; %Loop the following segment, using whatever type of loop you like and can make work. You are not required to use all of these lines, if you do not need them. X_new = input(\'What is the x-component of the next vector?\'); Y_new = input(\'What is the y-component of the next vector?\'); X = x + X_new; Y = y + Y_new; % The following does output, and does not need to be in the loop fprintf(\'The sum of all of these vectors is %5.4f units horizontally and %5.4f units vertically.\ \', X, Y)

Solution

Answer

prompt = \"Enter the number of times you want this section to run::\";

loop_num = input(prompt);

for i = 1:loop_num

%%body of loop where the sum of the vectors is calculated

end

 Here is a bit of Matlab code that adds two 2-Dimensional vectors together by getting the components and summing the components. Use the blank lines to create a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site