我試圖將簡單的C代碼轉換爲matlab,但是我一開始似乎很清楚,這個細分市場在做什麼? SIZE_N2 = 25,w = 533,h = 800將此C++代碼轉換爲Matlab
//Init the L matrix. L is a sparse matrix that only contains SIZE_N2 non-zero elements per row.
//We store the L matrix in an array with one row per image pixel and one column per non-zero value.
//Each array cell accumulates values according to equation 11.
LMatrix = new double* [w*h];
for(i=0; i<w*h; i++){
LMatrix[i] = new double[SIZE_N2];
for(j=0; j<SIZE_N2; j++){
LMatrix[i][j] = 0;
}
}
是不是在Matlab中創建這個矩陣?
LMatrix =零(SIZE_N2,w * h);
當我運行這個代碼,矩陣超出邊界上一個for循環。
任何人都知道這個的正確實施?
謝謝!
請注意,你有C++,而不是C代碼。 (你應該改變標籤) –
我認爲你不需要循環,絕對做'LMatrix =零(SIZE_N2,w * h)',希望解決這個問題,矩陣的維數將是'SIZE_N2 x(w * h)' – Subinoy
但我正是那樣做的!但是,在代碼的下一部分,它超出了矩陣大小的大小。那麼,你是否說我做了正確的工作來改變它? – Yasin