how to read a text file that contains a sinewave form in one column,then plot it on matlab?
9 views (last 30 days)
I would like to plot a signal that is saved in text file where I know the sampling frequency.
I tried this code but did not work properly.
Fs=10e3; %sample frequency
fileID = fopen('sine50Hz.txt','w');
this is what I get
the code for generating this sinewave is:
fsig50=50; %signal frequency
William Rose on 30 Sep 2022
It seems that you have opened the file for writing ('w') which erases the exisitng file, if it exists. You write the time vector to the file. Then you attempt to read from the file with fscanf(). You would have to close it first, the open it for reading ('r'). I'm not sure exactly what you are trying to do. If the text file already exists, with 2 columns of data (time and the sine wave), then do
If the text file is just 1 column of data, the sine wave without the times, the do the following:
Try it. Good luck.