Thursday, 19 September 2013

Create output file in matlab containing numeric and string cells

Create output file in matlab containing numeric and string cells

I am currently working on a project where I have to program the same tool
both in Matlab and R and compare both software options. I started in R and
now I am translating the code to Matlab but I am now stuck at the most
important part. The output file that the tool creates after doing the
analysis. Basically, my tool makes an analysis that loops n times, and
after each loop I get many variables that go into an output table. So, to
be more clear, after each loop I get variables:
A = 123
B = 456
C = 'string1'
D = 'string2'
E = 789
The values in each variable change after each loop, I just want to make
clear that the variables are both numeric and string values since this is
what causes my problem.
In R what I do after each loop is:
outp <- cbind(A,B,C,D,E)
and create a data frame containing each variable in one cell arranged
horizontally to afterwards add the result of each loop vertically in a new
data frame:
outp2 <- rbind(outp2,outp)
so in the end I get a data frame (outp2) with A,B,C,D,E columns and n rows
containing the values of each variable after each loop. So at the end of
the looping process I can use write.csv function and create an output file
of outp2 that contains both numeric and string columns.
I tried to do this in Matlab but I cannot find a function that can join
the data in the same way I am doing it in R because using brackets '[]'
only allows me to join numeric kind of variables. So basically my question
is: How can I replicate what I am doing in R in Matlab?
I hope I was clear enough, I found it a bit hard to explain.

No comments:

Post a Comment