Problem opening a .txt file

10 ビュー (過去 30 日間)
Juan Pedro Martinez
Juan Pedro Martinez 2022 年 6 月 9 日
回答済み: Image Analyst 2022 年 6 月 9 日
I got a txt. file with data from an oscilloscope. Matlab does not open correctly the file. If I run:
fid=fopen('filterACspot.txt');
dataACspot=fprintf(fid,'%f',[4,12]);
fclose(fid);
it returns a 0 value. I tried to open 'filterACspot.txt' in matlab and copy one line straight into a vector. It works, returns a 1x20480 double, which is the size i expect. When I try to plot those vectors selected individually, y get the following error:
Error using plot
Data must be a single input of y-values or one or more pairs of x- and y-values.
All this leads me to believe the data in the text file, even though looks like regular numbers, is formatted incorrectly. But I have not found how to check and how to correct it. Any pointers? I attach the file. Thank you

採用された回答

Image Analyst
Image Analyst 2022 年 6 月 9 日
You didn't specify 'rt' or 'wt' in your fopen. Why are you opening an existing file and then writing to it?
If you want to overwrite it you need to specify 'wt'.
If you want to read from it you need to specify 'rt' and use either fgetl or textscan, or better yet use readmatrix or importdata.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by