Student Support Forum: 'unexpected output from matrix creation' topicStudent Support Forum > General > "unexpected output from matrix creation"

 Next Comment > Help | Reply To Topic
 Author Comment/Response Nathan C. Lee 10/31/02 08:54am I'm getting a curious result from the creation of a matrix using a function containing several If operators. Please see the notebook file attached or at my URL for a better view. What I'm trying to do is generate an nxn square matrix within some specific parameters (defined by my if statements). Here is my function: F[n_]=Table[If[i!=n&&i==j,1,If[i>j||j==n,(-1)^(i+j-1),0]],{i,1,3},{j,1,3}]; F[3] And it outputs a matrix with the last column containing the _functions_ meant to be evaluated, and not their actual result. When I replace the 'n' terms in the function above, I get the expected result. Table[If[i!=3&&i==j,1,If[i>j||j==3,(-1)^(i+j-1),0]],{i,1,3},{j,1,3}]; Any ideas why I can't get the result when I use a variable? I'm also wondering why I can't use the variable n to define my range, as in F[n_]=Table[If[i!=n&&i==j,1,If[i>j||j==n,(-1)^(i+j-1),0]],{i,1,n},{j,1,n}]; This isn't as pressing an issue, but it would be nice if I could do this. Attachment: mathematicaissue.nb, URL: http://homepage.mac.com/keeper/uc/mathematicaissue.nb,

 Subject (listing for 'unexpected output from matrix creation') Author Date Posted unexpected output from matrix creation Nathan C. Lee 10/31/02 08:54am Re: unexpected output from matrix creation Forum Modera... 11/02/02 4:04pm
 Next Comment > Help | Reply To Topic