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 Center および File ExchangeText Files についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by