# How to extract data from txt file and plot spectogram?

--

Hello,

I have a large sample of data (100000 samples) in txt file consisting of time and amplitude of the signal.

I want to plot spectogram. The code is not at all able to extract the .txt file at all along the path.

Kindly advice me as how to extract data from txt file when data is very large as it is in my case and hence to plot the spectogram.

The code is as below:

`close all;`

freq_sam = 100000; % samples in tt1 data

period_tt1 = 0.005; % time period

freq_tt1 = 1/period_tt1; % frequency

`data = importdata('D:\Data_tokamak\data\obp.txt');`

x_data = data(:,1);

y_data = data(:,2);

disp(x_data);

disp(y_data);

signal_tt1 = data;

fft_tt1 = fft(signal_tt1); % fourier transform

fft_tt1 = fftshift(fft_tt1); % performing fft shift

f = freq_sam/2*linspace(-1,1,freq_sam);

figure;

plot(f, fft_tt1);

*NOTE:-*

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

I prefer the pspectrum function for these analyses. See specifically Spectrogram and Reassigned Spectrogram of Chirp for an example of returning the data and plotting it as well.

`data = readmatrix('D:\Data_tokamak\data\obp.txt');`

x_data = data(:,1);

y_data = data(:,2);

Ts = mean(diff(x_data))

Fs = 1/Ts;figure

pspectrum(y_data, Fs, 'spectrogram') % Plot 'pspectrum' 'spectrogram'[sp,fp,tp] = pspectrum(y_data,fs,"spectrogram"); % Return Values, Then Plotfigure

waterfall(fp,tp,sp')

set(gca,XDir="reverse",View=[60 60])

ylabel("Time (s)")

**SEE COMPLETE ANSWER CLICK THE LINK**