Problem opening a .txt file

11 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by