Java failed to read and print matrix from txt file -


i have matrix txt file (11x25).

0.611104586 0.421137301 0.148175838 0.093093778 0.528511286 0.418664735 0.501390139 0.02206688  0.103546871 0.633455719 0.265081895 0.451747788 0.329214309 0.60249002  0.662946576 0.44162406  0.371196059 0.084083877 0.589799899 0.18569671  0.034511745 0.302195181 0.278790488 0.031898972 0.697455224 0   0.126780289 0.744394666 0.48235826  0.757190046 0   0.982900393 0   0.428819183 0.341336135 0.248345722 0.340234421 0   0.505015206 0.844733493 0   0.520242556 0.839144273 0.944768681 0   0   0.911173675 0.96852497  0.513269179 0 0.719522104 0.904803048 0   0.438443555 0.619019934 0.770586942 0.035069914 0.284726903 0   0.900156226 0   0.614178016 0.756121647 0   0.482162641 0.346972852 0   0.530160102 0.607970986 0   0   0.70776022  0.630313049 0.537430321 0.429637915 0.965552324 0.237316539 0   0.675540672 0.02245449  0   0.906837513 0.046865469 0.985370941 0   0   0.581136159 0   0.731418151 0.410065655 0.185012435 0.810102943 0.061834628 0.760408343 0.52844337  0.106327038 0.764641701 0   0.241043197 0.138591668 0.785265388 0.245375911 0.003825113 0.392088166 0.746347629 0   0.865455277 0   0.320064792 0.469631124 0.275800621 0.226402945 0.196849125 0.3767231   0   0.504222038 0.252534767 0   0.108825926 0.038854648 0   0   0.837990169 0.233463218 0.973794244 0   0.369290247 0.391632502 0.966710703 0.456646601 0.744378787 0.500206874 0.429575161 0.4157577   0.682093427 0   0   0.88518823  0.545062518 0.844007009 0.209436674 0.532083535 0.643254912 0.022206966 0.972272975 0.207677119 0.619557286 0.684530833 0.039768814 0.566273215 0.719277709 0.370218186 0   0.528553716 0   0.474043295 0.644709559 0.096042971 0.078666296 0.667435055 0.440727479 0.859297227 0.18165689  0.068277826 0.289860387 0.208112415 0.626884285 0.295818382 0.756532711 0   0.470774563 0.560703247 0.040089639 0   0.910059573 0.350135065 0.250992266 0   0.762270073 0.649714246 0.382709691 0   0.434548143 0.096899503 0.221095404 0.207416989 0   0.142452936 0.063563437 0.519824118 0.318727424 0.033631564 0.34535148  0   0.050335104 0   0.085647088 0   0.970307046 0.489823431 0.549077625 0.786267574 0.310947619 0   0.855403201 0.356727854 0.448585797 0.858197183 0.164926857 0.632894281 0.883520503 0.477562449 0   0   0.054450728 0.581420285 0.405555966 0   0.595676984 0.581284627 0.294128393 0   0.022840426 0.442097113 0.168690247 0.773515517 0.667867116 0   0.384918608 0.495617591 0.960445903 0   0.521981671 0.582565937 0.000392407 0.729931754 0.003648767 0   0.959536544 0.308279485 0   0.992524156 0.078062129 0   0.425848147 0   0.146881857 0.488967009 0.914247178 0.556155216 0.20589258  0.113521908 0.215750666 0.241288747 0.803876238 0   0.219172738 0       0   0.560754999 0   0.480321026 0.21864147  0   0.756257475 0.99148594  0.795855095 0.947866607 0.642933671 0.988902986 0   0   0.865736296 0.745107083 0.125387319 

trying read, store , print matrix form in matrix[i][j], wont read , print properly. here part of code in java

            static double [][] matrix = new double[20][50];              filereader fr = new filereader("tm.txt");             bufferedreader br = new bufferedreader(fr);              string line = null;             int linecount = 0;             while ((line = br.readline()) != null)             {                 string[] numbers = line.split(" ");                 ( int = 0 ; < 25 ; i++) {                      matrix[linecount][i] = double.parsedouble(numbers[i].trim());                     system.out.println(matrix[linecount][i] + " " + + " " +linecount);                   }                 linecount++;              }             system.out.println(matrix[1][5] + " ");//note 2              ( int = 0; < 10; i++){                 (int j = 0; j < 25; j++){                      system.out.println(matrix[i][j] + " ");                  }              }//note 3. 

note 1. error message: (solved. :))

exception in thread "main" java.lang.error: unresolved compilation problem:  cannot resolved variable 

note 2. print out 0.0, no matter put in matrix, e.g. matrix[1][2].

note 3. want print out matrix, gives 0.

the issue note 2 , 3 still remain. not sure if need store matrix reading txt file in order use it.

thanks help!

i cannot resolved variable.

       while ((line = br.readline()) != null)         {             string[] numbers = line.split("\\w+");             ( int = 0 ; < 25 ; i++){                   matrix[linecount][i] = double.parsedouble(numbers[i].trim());                  system.out.println(matrix[linecount][i] + " " + + " " +linecount);             }//note 1             linecount++;          } 

and 1 more is

 static double [][] matrix = new double[20][25];//just increase size 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -