how to combine two arrays?

Hi, I have read a file with xlsread as
[~,~,all_data]=xlsread('test.csv')
all_data structure is as follow
'000991.XSHG' 'open' 'close' 'high' 'low' 'total_turnover' 'volume'
'2011-08-02' [5.9219e+03] [5.9021e+03] [5.9219e+03] [5.8162e+03] [ 6.7581e+09] [3.8463e+10]
'2011-08-03' [5.8552e+03] [5.9083e+03] [5.9478e+03] [5.8338e+03] [ 6.3747e+09] [3.4054e+10]
I try to extend two row with 0. I met problem with I use
[all_data,zeros(3,3)]
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
And when I want to change a array as
a1={'cap','earn','PE')
a2=zeros(2,3)
a=[a1;a2]
same error happened.
Who know how to solve this problem?

Answers (1)

Jan
Jan on 14 Jan 2018
Edited: Jan on 14 Jan 2018
Your all_data is a cell array. And in
a1 = {'cap','earn','PE'} % Trailing ) replaced by }
a2 = zeros(2,3)
a = [a1;a2]
you try to join a cell array and a double array. Convert the 2nd array to a cell array at first:
a1 = {'cap','earn','PE'}
a2 = num2cell(zeros(2,3))
a = [a1;a2]

Categories

Asked:

on 14 Jan 2018

Commented:

on 6 Apr 2020

Community Treasure Hunt

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

Start Hunting!