We can generate a random 6 times 6 matrix A whose entries consist entirely of ze
ID: 3636336 • Letter: W
Question
We can generate a random 6 times 6 matrix A whose entries consist entirely of zeros and ones by setting A = round(rand(G)) What percentage of these random 0-1 matrices are singular? You can estimate the percentage using MATLAB by setting y = zeros(1,100); and then generating 100 test matrices and setting y(j)=1 if the matrix is singular and 0 otherwise. the easy way to do this in MATLAB is to use a for loop. You can also MATLAB function sum. For any position integer n. we can generate a random 6 times 6 matrix A whose entries are integers from 0 to n by setting A = round(n*rand(6)) What percentage of random integer matrices generated in this manner will be singular if n=3? If n=6? If n=10?each case, generate 100 test matrices and determine how many of the matrices are singular.Explanation / Answer
Here's a function that will do this for you. Just put in the "n" from the problem and then how many matrices you want to compute. for example, to do part a you would write: singular(1,100); And it will tell you what percent it got. Here's the code: %This function takes input (n) from your problem and generates matrix %A=round(n*rand(6)). It than dtermines whether or not it is singular, and %estimates a percentage of singular matrices. "num" is the number of %matrices it generates to calculate the percentage. function p=singular(n,num); %build the counting vector y=zeros(1,num); %Set up the loop to repeatedly generate matricies for i=1:num A=round(n*rand(6)); %Test matrix to see if it is singular if det(A)==0 y(i)=1; end end %Now compute the percentage p=sum(y)/num*100; %display percentage fprintf('%g percent were singular ',p) end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.