0

The following code doesn't have any output in the console window.I want to code the task in the image. Can help please,Thanks in advance comupute a normalized matrix

public class Normalize {
    static int m,n,p,k,j,i;
    static int x[][]=new int[m][n];
    static double h[]=new double[p];
    public static double[] eigenvector(int [][]x) {
        double sum=0;
        for(p=1; p<=k; p++){
            {
                for(i=1; i<=m; i++){
                    for(j=1; j<=n; j++){
                    double px=Math.pow(x[i][j], 2);
                    sum =sum+px;
                    }
                }
                h[p]=Math.sqrt(sum);
            }
        }
        return h;
    }


    public static void main(String[]args){
        int [][]x=new int[3][3];
        x[1][1]=1;
        x[1][2]=1;
        double h[]=eigenvector(x);
        for(p=1; p<=k; p++)
        {
        System.out.println("The normalzed matrix is of class p is" +h[p]);
    }
        System.exit(0);

}
Fredrik Widerberg
  • 3,050
  • 10
  • 29
  • 42
nounou
  • 1
  • 4
  • 3
    You have not initialized `k` – lucumt Jul 25 '18 at 09:08
  • 1
    Possible duplicate of [What is a debugger and how can it help me diagnose problems?](https://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) – Max Vollmer Jul 25 '18 at 09:25
  • I initialize k, but no output. – nounou Jul 25 '18 at 09:25
  • Where do you initialize k in the code above? With what value? If it's 0, it's normal to get no output. – StephaneM Jul 25 '18 at 09:28
  • I intialize k=1 and it work thank you sir – nounou Jul 25 '18 at 09:34
  • In the compilation i have this error message Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at atovic.Normalize.eigenvector(Normalize.java:18) at atovic.Normalize.main(Normalize.java:29) – nounou Jul 25 '18 at 09:43

0 Answers0