Hi, i have this error when running my regression programme: Error using - Matrix dimensions must agree. Error in mpg_regression (line 55) X21 = X11-mean(X11); My arrays are all 1x82 (i checked using disp(size())). Any help would be appreciated.
Ältere Kommentare anzeigen
mpg = importdata('carmpgdat.txt', '\t', 1);
VOL = mpg.data(:, 1);
HP = mpg.data(:, 2);
MPG = mpg.data(:, 3);
SP = mpg.data(:, 4);
WT = mpg.data(:, 5);
GPM = 1./MPG;
disp(size(VOL));
disp(size(HP));
disp(size(SP));
disp(size(WT));
X11 = [VOL HP SP WT];
mdl = fitlm(X11,MPG);
r2_1 = mdl.squared.Ordinary;
r2adj_1 = mdl.Rsquared.Adjusted;
p1 = 4;
X21 = X11-mean(X11);
X31 = X21/std(X21);
KS_1 = kstest2(X31, MPG);
1 Kommentar
Greg
am 24 Dez. 2016
Except the only array in question is absolutely NOT 1x82. X11 = [VOL HP SP WT]; makes X11 either 1x328 or 4x82 (and as I look at your other code, I'm pretty sure it's actually 82x1 making X11 82x4). You are likely trying to subtract a 1x4 from an 82x4. In R2016b with implicit expansion, this should result in a successful subtraction. Prior to R2016b, this won't work.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Whos finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!