how to concatenate in matlab?
조회 수: 2 (최근 30일)
이전 댓글 표시
A=power; load ;density;
b=_mean;_std;_max;_min;
A is a set of string in .txt file 1 and B is a set of string in .txt file 2. I need to concatenate the corresponding strings in both text files and put it in the excel sheet, such that ,i need output as,
power_mean power_std power_max power_min load_mean and so on.
It should be stored in excel in a row(1*12). its nothing like creating header or label to my values. im stuck here... help me
댓글 수: 3
답변 (1개)
Andrei Bobrov
2013년 8월 12일
편집: Andrei Bobrov
2013년 8월 12일
A={'power'; 'load' ;'density'};
b={'mean';'std';'max';'min'};
[ii,jj] = ndgrid(1:numel(b),1:numel(A));
out = reshape(strcat(A(jj),{'_'},b(ii)),1,[]);
ADD
nm = {'E:\header_01.txt','E:\header_02.txt'};
c1 = cell(1,2);
for jj = 1:2
f = fopen(nm{jj});
c = textscan(f,'%s');
fclose(f);
a1 = regexp(c{:},'\w*','match');
c1{jj} = cat(1,a1{:});
end
n = cellfun('length',c1);
[ii,jj] = ndgrid(1:n(2),1:n(1));
out = reshape(strcat(c1{1}(jj),{'_'},c1{2}(ii)),1,[]);
댓글 수: 4
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!