MATLAB: I have 4 different dimension matrices(A:1100X1, B:2200X1,C: 3300X1,D:3300X1)..I want to keep all 4 in one matrix..

matrix manipulation

Hi, I have 4 different dimension matrices(A:1100X1, B:2200X1,C: 3300X1,D:3300X1)..I want to keep all 4 in one matrix..
the code written as
clc
clear all
format compact
warning off
L = []; indexgood=1;
%mrsgarch_n
load mrsgarch_n
eval(['L(:,',num2str(indexgood),') = Loglike(:);']);
indexgood=indexgood+1;
% MRSGARCH-t2
load mrsgarch_t2
eval(['L(:,',num2str(indexgood),') = Loglike(:);']);
indexgood=indexgood+1;
% MRSGARCH-GED
load mrsgarch_g
eval(['L(:,',num2str(indexgood),') = Loglike(:);']);
indexgood=indexgood+1;
% MRSGARCH-t1
load mrsgarch_t
eval(['L(:,',num2str(indexgood),') = Loglike(:);']);
indexgood=indexgood+1;
cd junk\VF
save loglik.txt L -ascii -double -tabs
cd ..
cd ..
when I run this code.. the following error msg is coming..
??? Subscripted assignment dimension mismatch.
Error in ==> ooslikelihoods at 18 eval(['L(:,',num2str(indexgood),') = Loglike(:);']);
Thanks
Kishore

Best Answer

I assume each of your data file contains the same variable Loglike, but the size is different from file to file, first is 1100x1, second is 2200x1, etc. You want to combine them.
Try this:
L = [];
load mrsgarch_n
L=[L;Loglike];
load mrsgarch_t2
L=[L;Loglike];
load mrsgarch_g
L=[L;Loglike];
load mrsgarch_t
L=[L;Loglike];
Related Question