0

I want my code to prompt the user for a list of eigenvalues, run through every possible 0,1 matrix with that number of vertices, create a list of all possible eigenvalues, and if any match what the user puts in, it returns the corresponding matrix. Got stuck here where it won't iterate correctly:

prompt='How many eigenvalues: ';
x=input(prompt);
prompt2='Enter Eignevalues: ';
y=input(prompt2,'s');
combs=dec2base(0:power(2,x*x)-1,2)-'0';
combs_matshaped=reshape(permute(combs,[3 2 1]),x,x,[]);
for l=combs_matshaped
    disp(eig(l))
end

Any ideas on how to structure the for loop?

Marouen
  • 907
  • 3
  • 13
  • 36

1 Answers1

0

1-you need to prompt the user for a tolerance as well.

2-round off the eig(l) by the tolerance

3-test if the given values belong to the rounded set through ismember something like ismember(str2num(prompt2),round(eig(l),tol))

EDIT

To generate a M by N binary matrix , use Mat = randi([0 1], M, N)

Marouen
  • 907
  • 3
  • 13
  • 36
  • Thank you for that! I have made a lot of changes, but the one part that I'm still having issues with is that when the for loop runs, it returns only vectors and not matrices. This leads to the program trying to take the eigenvalues of a vector (which does not work) instead of the matrix. Do you know how to reformat the for loop so that it takes the eigenvalues properly? – CharlesLyleLarue Nov 04 '17 at 00:00