what is the error here?

data1 = [data1,(text(k,6))];
Error using horzcat CAT arguments dimensions are not consistent.
Error in data1 = [data1,(text(k,6))];

4 件のコメント

Amr Hashem
Amr Hashem 2015 年 5 月 15 日
for Q=1:length(querymdr)
for k=1:length(text)
if datatext{Q,1}==text{k,1}
M=text(k,6);
data1 = [data1,(text(k,6))];
k=k+1;
end
end
end
James Tursa
James Tursa 2015 年 5 月 15 日
編集済み: James Tursa 2015 年 5 月 16 日
What are the contents of datatext and text? I.e., what are the underlying variable types and sizes?
Are you sure you want the test to be datatext{Q,1}==text{k,1} and not something like isequal(datatext{Q,1},text{k,1})?
Why are you manually incrementing the for-loop index k within the loop?
Amr Hashem
Amr Hashem 2015 年 5 月 16 日
this is the contets of datatext and text
datatext 5*6 cell text 8*6 cell
i want the answer to be:
ans 5*8 cell
Amr Hashem
Amr Hashem 2015 年 5 月 16 日
編集済み: per isakson 2015 年 5 月 16 日
any help, this is the code
for Q=1:length(querymdr)
for k=1:length(text)
if datatext{Q,1}==text{k,1}
datatext = [datatext,(text(k,6))];
end
end
end

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 5 月 17 日

0 投票

You need to find an empty position in datatext(Q,:) to assign into. For example,
nextslot = find(cellfun(@isempty,datatext(Q,:)));
if isempty(nextslot)
nextslot = size(datatext,2);
end
datatext{Q,nextslot} = text{k,6};
This will grow datatext wider if necessary in order to handle the new information.

カテゴリ

タグ

質問済み:

2015 年 5 月 15 日

回答済み:

2015 年 5 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by