Please provide the MATLAB code required to solve these problems, It ia a matrix
ID: 667447 • Letter: P
Question
Please provide the MATLAB code required to solve these problems, It ia a matrix with input 224463 should be an identity matrix with 2, 2, 4, 4, 6, 3 in place of the ones. Also for the plot in number 3 I got everything to work except in the exp(-2x) it wont do the -2, it will only accept exp(x), when i try exp(-2x) no plot is made. If you can explain that please do!
Write MATLAB program which takes 6 digit number as input, then creates an 6x6 matrix with digits of the input number as diagonal elements and zero elsewhere using FOR loops.
2- (a) (1596) Write the MATLAB program which takes 6 digits number as input, then creates an 6x6 matrix with digits of the input number as diagonal elements and zeroes elsewhere using for loops. Then, execute the program using your first six digits of your student ID as input. (Hint: You may use these commands: rem(x,y) and floor(x) (b) (15%) Write the MATLAB program that asks the user for an integer number and then computes the factorial of that number using while or for loop. 3- Plot 0 xsS in different (1096) f(x)-cos(x) + exp(-2x), g(x)=sin(x),h(x)-1/2x-1 colors in one graph with all label ··(1096):=sin(r) / r with r-Vx2 +y-8 10%) sin(r)/1. with 1, Ix + 8,-8 y 8 xExplanation / Answer
(a)
no=input('Enter 6 digit number');
matr(6);
for a = 0:5
c=mod(no,10);
no=no/10;
for b=0:5
if a=b
matr(a,b) =c;
else
matr(a,b)=0;
end;
end;
end;
(b)
no=input('Enter number');
fact=1;
for a = 1:no
fact=fact*a;
end;
fprintf('Factorial is %d ',fact);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.