Problem opening a .txt file

11 visualizaciones (últimos 30 días)
Juan Pedro Martinez
Juan Pedro Martinez el 9 de Jun. de 2022
Respondida: Image Analyst el 9 de Jun. de 2022
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

Respuesta aceptada

Image Analyst
Image Analyst el 9 de Jun. de 2022
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.

Más respuestas (0)

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by