我有一個維度365x28(即365行和28列)的二維矩陣。我正在嘗試使用以下代碼進行標準化:二維數組的標準化
public static void main(String args[]) throws Exception {
double[][] X = new double [365][28];
double[][] X_min = new double [1][28];
double[][] X_max = new double [1][28];
double[][] X_norm = null;
X_norm = normalize(X, X_min, X_max);// error in this line
public static double[][] normalize(double[][] ip_matrix, double[][] min_bound, double[][] max_bound)
{
double[][] mat1 = ip_matrix;
double[][] norm = new double[mat1.length][mat1[0].length];
for (int i = 0; i < mat1.length; i++)
{
for (int j = 0; j <= mat1[i].length; j++)
{
norm[i][j] = (mat1[i][j] - min_bound[i][j]/(max_bound[i][j] - min_bound[i][j]));// error in this line
}
}
return norm;
}
}
但是,當我運行這個我得到一個索引錯誤。我知道min_bound [i] [j]和max_bound [i] [j]有問題。但我不知道如何糾正這一點。任何人都可以幫助我嗎?提前致謝。
Error: exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
如果你發佈你所得到完整的錯誤這將是有益的。 – EkcenierK
yup ..我現在編輯它。 –
這段代碼給了我一個'ArrayIndexOutOfBoundsException:28' – ParkerHalo