필터 지우기
필터 지우기

concatenating characters in different column to a string

조회 수: 2 (최근 30일)
Rinachi Garg
Rinachi Garg 2012년 6월 4일
I want to store 1x5 array of strings ['a' 'b' 'c' 'd' 'e'] as a single string of 1x1 :'abcde'. How can I do that? I want to do this because if I export ['a' 'b' 'c' 'd' 'e'] to excel file then they appear in seperate columns. But I want to write them all in same cell.

채택된 답변

Walter Roberson
Walter Roberson 2012년 6월 4일
['a' 'b' 'c' 'd' 'e'] is not a 1 x 5 array of strings: it is a single string of length 5, 'abcde', exactly as you want.
{'a' 'b' 'c' 'd' 'e'} on the other hand would be a 1 x 5 cell array of strings. You can convert this cell array to a single string by using cell2mat()

추가 답변 (1개)

Image Analyst
Image Analyst 2012년 6월 4일
Try this:
% Create sample data.
charArray = ['a' 'b' 'c' 'd' 'e']
% Turn it into a cell array.
myCellArray = {charArray}
% Write to cell c3 of Excel.
sheetNumber = 1;
cellReference = 'C3';
xlswrite('test_sheet.xls', myCellArray, sheetNumber, cellReference);

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by