Reading a text file into an array

3 ビュー (過去 30 日間)
Jack
Jack 2020 年 11 月 7 日
回答済み: Ameer Hamza 2020 年 11 月 7 日
I want to read a text file called test that contains integers into an array. I keep recieving an error. How do I read a text file into an array?
% This is the code
fileID = fopen('Test.txt','r');
formatSpec = '%d %f';
sizeA = [2 Inf];
A = fscanf(fileID,formatSpec,sizeA);
fclose(fileID);

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 7 日
This error can occur if MATLAB cannot fine the file Test.txt. Make sure that the file is placed in the current folder or specify the complete path to the file.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by