필터 지우기
필터 지우기

Textscan Usage. One character in one cell.

조회 수: 1 (최근 30일)
Priya
Priya 2013년 4월 15일
I have a text file in which following characters are written
ABCDE
I want to store it in a cell array of order 1 X 5 , with each character in one cell.
I tried using Textscan as follows, but it gives only 1X1 cell with all characters in one cell.
Kindly Help.

채택된 답변

Friedrich
Friedrich 2013년 4월 15일
편집: Friedrich 2013년 4월 15일
Hi,
>> fid = fopen('in.txt')
>> data = textscan(fid,'%c')
data =
[5x1 char]
>> fclose(fid)
data is a 1x1 Cell which contains a 1x5 Char Array. And in the case you really need a cell you can use mat2cell:
new_data = mat2cell(data{1},ones(numel(data{1}),1),1)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by