Write a script that prompts the user to input the day month
Write a script that prompts the user to input the day, month, and year; determine the day of the year (the number of days including the current day). Be sure to take leap year into account. Use a for loop Test your code on the following dates: February 28, 2015 April 9,1976 October 12,1887 Create a script that performs the same function as repmat. The only built-in commands you may use are input, size, and disp. Honors option. Write your own code to perform matrix multiplication. Recall that to multiply two matrices, the inner dimensions must be the same. [A]_mn[B]_np = [C]_mp Every element in the resulting C matrix is obtained by: C_ij = sigma a_ik b_kj You code must be a function file and it must check to see if matrix multiplication can be performed on the provided matrices. Test your code for the following conditions: A= 2 -1 7 4 5 3 6 2 5 B= 6 4 2 1 9 -3 A= 2 -1 7 4 5 6 6 2 5 B= 6 4 2 1 9 -3
Solution
A=input(\'enter first matrix \');
B=input(\'enter second matrix \');
Sa=size(A);
Sb=size(B);
C=zeros(Sa(1),Sb(2));
if Sa(2)==Sb(1)
for m=1:Sa(1)
for n=1:Sb(2)
sum=0;
for p=1:Sb(1)
sum=sum+A(m,p).*B(p,n);
C(m,n)=sum;
end
end
end
C
else
disp(\'matrix dimensions not matching\');
end
>> m2
enter first matrix [2 -1 7;4 5 3;6 2 5]
enter second matrix [6 4;2 1;9 -3]
C =
73 -14
61 12
85 11
>> m2
enter first matrix [2 -1 7;4 5 3;6 2 5]
enter second matrix [6 4 2;1 9 -3]
matrix dimensions not matching
>>
