Hello every one
I have a text file contains:
1,24,85,90
23,36
34,36,39,56,85,86,90
34,59,67,85,86
39,85,93
I want to scan it
How can I do that , please help me!

 채택된 답변

Walter Roberson
Walter Roberson 2020년 1월 8일

0 개 추천

filename = 'AppropriateName.txt';
S = fileread(filename);
L = regexp(S, '\r?\n', 'split');
data = cellfun(@(s) str2double(regexp(s, ',', 'split')), L, 'uniform', 0);
The result will be a cell array with one entry per line, with each entry being the numeric data from the corresponding line.

추가 답변 (1개)

Bhaskar R
Bhaskar R 2020년 1월 8일

0 개 추천

data = readtable('yourfile.txt', 'Delimiter', ',',...
'HeaderLines', 0, 'ReadVariableNames',false, 'Format', '%d');

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

질문:

2020년 1월 8일

답변:

2020년 1월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by