Creating row-concatenated matrix in Matlab
How do I create a concatenated matrix in Matlab which would give the result below?
[0.01 0.01 error1] [0.01 0.03 error2] ... [30 30 error64]
So far, what I have tried is below.
C = [0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30]; sigma = [0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30]; m = zeros(64,3); for ci = C for si = sigma train = svmTrain(X, y, ci, @(x1, x2) gaussianKernel(x1, x2, si)); pred = svmPredict(train, X); error = mean(double(pred ~= y)) m = [m ; [C,sigma,error]]; end end
I expect a 64 X 3 column matrix.
It seems like the code you provided basically does that. You should be starting off with an empty matrix m.
m = ; % Initialize empty result matrix m for ci = C for si = sigma error = % Calculate error here m = [m ; [C,sigma,error]]; % concatenate new row onto m. end end