how can concat cell array with array?

4 次查看(过去 30 天)
fatemeh
fatemeh 2013-10-19
评论: Cedric 2013-10-19
for example i have cell arrays s{i} ,i want s{i}s pose in one column and another vector like f=[3 4 .....] pose in another column .

回答(2 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-10-19
s=[s num2cell(yourarray)]
  1 个评论
fatemeh
fatemeh 2013-10-19
but this give this error: Error using horzcat CAT arguments dimensions are not consistent.
Error in prog (line 56) y= [s1{h} num2cell(f(h))]

请先登录,再进行评论。


Cedric
Cedric 2013-10-19
编辑:Cedric 2013-10-19
s = {1; 2; 3; 4} ; % Column cell array.
f = [10 20 30 40] ; % Row numeric array.
c = [s, num2cell(f.')] ;
  4 个评论
fatemeh
fatemeh 2013-10-19
h is the index for a for loop ,each s1{h} is the 7*4 array and f(h) produce vector at each time, i want these are both in a one matrix... h =1000
Cedric
Cedric 2013-10-19
If you want to concatenate horizontally the content of cells of s1 and the output of f (assuming that f is a function), their number of columns must match. This means that you have to check that f outputs a 7x1 vector (and not 1x7, otherwise you have to transpose it).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by