concatenate 2 matrix in loop "previous iteration"?

i am trying to concatenateconcatenate two matrix
the output i get same line not append previous iterations C with new C
5.0000 3.6000 1.4000 0.2000
5.0000 3.6000 1.4000 0.2000
while(i ~=4)
Datachunk(i) = next_line;
i = i + 1;
next_line = fgetl(fid);
C = cell2mat(textscan(next_line,'%f %f %f %f','Delimiter', ',','CollectOutput', true));
C4 = [C;C];
end

 採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 7 月 27 日
編集済み: KALYAN ACHARJYA 2019 年 7 月 27 日

0 投票

May be you replaced the privious C with current C, use copy privious C with other variable and do the same.
while(i ~=4)
Datachunk(i) = next_line;
i = i + 1;
next_line = fgetl(fid);
D=C; %privious C, do C initialization (before while loop) for 1st iteration.
C=cell2mat(textscan(next_line,'%f %f %f %f','Delimiter', ',','CollectOutput', true));
C=[D;C];
end
Hope I undestand the question, if not let me know, I will happly delete the answer.

5 件のコメント

E
E 2019 年 7 月 27 日
really that what happened it be replaced
i did this but not working
V=C;
C4 = [C;V]
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 7 月 27 日
編集済み: KALYAN ACHARJYA 2019 年 7 月 27 日
Have you initialize C (before while loop) for 1st iteration? Try the following one-
C=zeros(1,4);
while(i ~=4)
Datachunk(i)=next_line;
i=i+1;
next_line = fgetl(fid);
D=C; %privious C, do C initialization (before while loop) for 1st iteration.
C=cell2mat(textscan(next_line,'%f %f %f %f','Delimiter', ',','CollectOutput', true));
C=[D;C];
end
Let me know is it working?
E
E 2019 年 7 月 27 日
now it is working
while(i ~=4)
Datachunk(i) = next_line;
i = i + 1;
next_line = fgetl(fid);
C = cell2mat(textscan(next_line,'%f %f %f %f','Delimiter', ',','CollectOutput', true));
C4 = [C4;C];
end
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 7 月 27 日
編集済み: KALYAN ACHARJYA 2019 年 7 月 27 日
OK
C=[D;C];
E
E 2019 年 7 月 27 日
thanks so much

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

E
E
2019 年 7 月 27 日

コメント済み:

E
E
2019 年 7 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by