Can i append a matrix with integers and a matrix with string on it

Hi and thank you for your time.
>> Jan=randi([-1 5 ],5,1);
>> Feb=randi([-8 5 ],5,1);
>> March=randi([2 5 ],5,1);
>> April=randi([9 15 ],5,1);
>> May=randi([15 25 ],5,1);
>> June=randi([19 30 ],5,1);
>> July=randi([22 32 ],5,1);
>> August=randi([6 15 ],5,1);
>> September=randi([1 10 ],5,1);
>> October=randi([1 5], 5,1);
>> October=randi([1 5], 5,1);
>> November=randi([-4 2 ],5,1);
>> December=randi([-4,0],5,1);
>>Year=(00:4)';
>>%Creating a matrix for years and combining with temperatures
>>Tempmatrix=[Year,Jan,Feb,March,April,May,June,July,August,October,November,December];
>> Name={'Year',' Jan',' Feb',' Mar',' Apr',' May',' Jun',' Jul',' Aug',' Sep',' Oct',' Nov',' Dec'};
%I am wondering is there any way to combine both string matrix and integer matrix.I tried >> save tempmatrix.dat Tempmatrix -ascii
>> save tempmatrix.dat Name -ascii -append
%Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'Name' not written to file.

Answers (1)

You can use cell array
names={'a' 'b' 'c'}
data=[1 2 3;4 5 6]
out=[names;num2cell(data)]
You can also convert to dataset
call2dataset(out)

2 Comments

Jananan commented
Thanks Azzi, it was helpful
Jananan, You can thank him by Accepting his answer and voting for his answer.

Sign in to comment.

Asked:

on 30 Apr 2014

Commented:

on 30 Apr 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!