正如在評論中提到的,你正在搞亂矩陣大小。
你創建你的值的方式seasonParam變成5x26矩陣。和C a 1x26矩陣。你正在模擬一個不確定的方程組,它可以有多種解決方案。
在這種情況下,算法幸運的是,C的一些值爲1!這意味着在解決方案(seasonParam)中的所有26 5x1向量中,只需將乘以1的那些向量設置爲結果值(logprice_hour_seas)即可完美匹配!因此,您的解決方案seasonParam是
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
5.2560 5.2151 5.2324 5.2224 5.2292
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
整個模型是沒有意義的,所以我假定你是剛剛搞亂了尺寸。 請嘗試以下操作:
logprice_hour_seas=[5.2560 5.2151 5.2324 5.2224 5.2292]';
PriceTimes = [0:1/8760:4/8760]';
seasonMatrix = @(t) [sin(2.*pi.*t) cos(2.*pi.*t) sin(4.*pi.*t) cos(4.*pi.*t) t ones(size(t, 1), 1)];
C = seasonMatrix(PriceTimes);
seasonParam = C\logprice_hour_seas;