フィルターのクリア

Input/Outputting values

1 回表示 (過去 30 日間)
Fergal Ahern
Fergal Ahern 2019 年 5 月 13 日
編集済み: Dvir Haberman 2019 年 5 月 14 日
How do I input and output values to a txt. file using MATLAB
Thanks

採用された回答

Dvir Haberman
Dvir Haberman 2019 年 5 月 14 日
編集済み: Dvir Haberman 2019 年 5 月 14 日
Hi,
Use fopen and fclose to handle these files.
use fopen to get the file id (pay that in case of failure fileID will be -1 )
Read the full info in this link.
shortly:
Premission 'r' to read and 'w' to write.
fileID = fopen(fullfilename,'r')
if(fileID!=-1)
% do something. use fgetl
end
Then I usually use fgetl to process every line and status feof to know if the file ended but there are more ways of course.
while ~feof(fileID)
tline(k) = fgetl(fileID)
end
dont forget to close the file afterwards
fclose(fileID)
After that when you want to write to a file open it with the 'w' permission and use fprintf to write to a file
fprintf(fileID,formatSpec,A1,...,An)
Again, remember to close the file when you're done with fclose
Hope this helps

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by