0% found this document useful (0 votes)
20 views2 pages

%rows %columns: 'Problem 9.a/n' 'Enter The Number of A Row' 'Enter The Number of A Column'

This document contains code to solve several math problems: 1) Problems 9a, 9b, and 9c generate matrices by multiplying the row and column indices and storing the results. 2) Problem 10 uses a while loop to find the smallest value of i such that 2*7*i squared is greater than a goal of 40000. 3) Problem 11 compares the elements of two matrices, A and B, of the same size and generates a new matrix C where matching elements are copied over and non-matches are set to 0. The results are then displayed.

Uploaded by

Ryan S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

%rows %columns: 'Problem 9.a/n' 'Enter The Number of A Row' 'Enter The Number of A Column'

This document contains code to solve several math problems: 1) Problems 9a, 9b, and 9c generate matrices by multiplying the row and column indices and storing the results. 2) Problem 10 uses a while loop to find the smallest value of i such that 2*7*i squared is greater than a goal of 40000. 3) Problem 11 compares the elements of two matrices, A and B, of the same size and generates a new matrix C where matching elements are copied over and non-matches are set to 0. The results are then displayed.

Uploaded by

Ryan S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

fprintf('Problem 9.

a\n');

A = input('enter the number of a row'); %rows


B = input('enter the number of a column'); %columns
M = zeros(A,B);

for i = 1:A
for j = 1:B
M(i,j) = i*j;
end;
end;
disp(M); %return M

fprintf('Problem 9.b\n');

A = input('enter the number of a row'); %rows


B = input('enter the number of a column'); %columns
M = zeros(A,B);

for i = 1:A
for j = 1:B
M(i,j) = i*j;
end;
end;
disp(M); %return M

fprintf('Problem 9.c\n');

A = input('enter the number of a row'); %rows


B = input('enter the number of a column'); %columns
M = zeros(A,B);

for i = 1:A
for j = 1:B
M(i,j) = i*j;
end;
end;
disp(M);

fprintf('Problem 10\n');

goal = 40000;
s = 0;
i = 1;
while 1
s = 2*7*i;
if s^2 > goal
break
end
i = i+1;
end
disp(s);
fprintf('Problem 11\n');
A = [9.00 4.00 2.00;7.00 5.00 3.00;6.00 8.00 9.00];
B = [5.00 4.00 3.00;7.00 6.00 8.00;9.00 2.00 9.00];
a = 3;
b = 3;
C = zeros(a,b);

for i = 1:a
for j = 1:b
if A(i,j)== B(i,j)
C(i,j) = A(i,j);
else
C(i,j) = 0;
end;
end;
end;

disp(C);

You might also like