Formatting read data from text files

조회 수: 2 (최근 30일)
Grace
Grace 2023년 4월 4일
답변: dpb 2023년 4월 4일
%I am trying to display the text that is read in a formatted method instead of a single line
%Attached is the test files
clc
clear
Inputfile = fopen('Aarakocra.txt', 'r')
text_data =fscanf(Inputfile, "%s\n")

채택된 답변

Les Beckham
Les Beckham 2023년 4월 4일
text_data = fileread('Question.txt');
disp(text_data)
Hello I am trying to format this text- Is there anyway I can print the same format to the command window simply?

추가 답변 (1개)

dpb
dpb 2023년 4월 4일
txt=readlines('YourInputFile.txt'); % read text file as string array
fprintf('%s\n',txt) % dumpt to command window as is
However, if the only purpose is to have the text go across the screen, there's not even any reason to actually read it into memory...
type('YourInputFile.txt'); % echo a text file to command window verbatim

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by