I have 4 different dimension matrices(A:1100X1, B:2200X1,C: 3300X1,D:3300X1)..I want to keep all 4 in one matrix..
Show older comments
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
3 Comments
Fangjun Jiang
on 4 Oct 2011
What are you trying to do? Your code looks awkward. How does your code relate to the question in your title?
Kishore Dhavala
on 4 Oct 2011
Walter Roberson
on 4 Oct 2011
That's either a good example of bad programming, or else code written for MATLAB 4 or earlier.
Accepted Answer
More Answers (1)
Walter Roberson
on 4 Oct 2011
0 votes
First, please read:
Beyond that: it is not possible in MATLAB to have numeric arrays that have different column sizes. If you want to use save() specifically to create four columns of data of different sizes that load() would load in, then you cannot do that. There are other ways that it would be possible to get the data written out in to columns, but load() would not be able to handle the result.
Does your data need to be saved as text? If so, then what are the requirements imposed by what-ever program you plan to read it in with? It makes more sense to construct a solution that fits the needs of what you cannot change, then for us to suggest different things you might want to do.
2 Comments
Kishore Dhavala
on 4 Oct 2011
Walter Roberson
on 4 Oct 2011
Do you have control of how the other program reads the data? Or does it need a particular format? If it needs a particular format, what is that format? If it is expecting spaces to indicate that there are no more values in a column, then it is probably expecting each column to be a very specific width.
Is the other program able to treat NaN as indicating that there is no data?
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!