How to concatenate multiple files with 2 cell arrays each into one file in such way as the first cell array from the first file will go to the first column the second to the second column and so on in numerical order using for loop is fine...
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, there, I'm relatively inexperienced in matlab, and programming overall. So my code lower on the page may be dumb...
I'm trying to take in multiple files with 2 arrays of numbers each and concatenate all of them into a single file so first cell array from the first file will go into the first column in the new file, the second array from the first file will go into the second column of the new file. The first array from the second file will go into the third column of the new file, the second array of the second file will go into 4th column of the new file and so on...
Trying to think about the solution with for loop, not really works...
Any help is appreciated, thanks.
for i=1:length(Files)
if (i == 1)
tmp = load(Files{i},'-mat');
S(i).data1 = tmp.data1;
S(i).data2 = tmp.data2;
Data1{i} = S(i).data1;
Data1{i+1} = S(i).data2;
else
tmp = load(Files{i},'-mat');
S(i).data1 = tmp.data1;
S(i).data2 = tmp.data2;
Data1{i+1} = S(i).data2;
end
댓글 수: 0
채택된 답변
추가 답변 (2개)
Mark Sherstan
2018년 12월 14일
댓글 수: 2
madhan ravi
2018년 12월 14일
Thanks.
Tried it for my data, doesn't work:
-----"Warning: Input should be a string, character array, or cell array of character arrays."
and then more errors...
so the data that I'm trying to concatenate is an array of numbers,a column of numbers (maybe I'm confused about specificty of cell array definition in MATLAB...)
I'm loading the files into MATLAB using load with dot indexing form the listbox function (that has a list of file names in certain order) and passes this list of files into pushbutton function, in which each file is suppose to be loaded and from each file I take two number arrays/columns and put it in the new file...
madhan ravi
2018년 12월 14일
편집: madhan ravi
2018년 12월 14일
Mark Sherstan responds:
Please post your data. Also use comments to respond and dont create another answer.
madhan ravi
2018년 12월 14일
댓글 수: 7
Mark Sherstan
2018년 12월 14일
Sorry for the disconnect. The best I can offer you is whatever direction my first solution gives you. Hopefully someone else can help.
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!