Converting time and velocity to frequency then plotting

I'm trying to extract data from a ".csv" file but want it to be two specific columns and start at a specific row (until the end of those columns) then use that data to convert it to frequency then plot that.
I have been given time and velocity (vertical).

7 commentaires

Can you post a screenshot of your spreadsheet, in order to see it clearly
Julie Huynh
Julie Huynh le 16 Fév 2022
Modifié(e) : Julie Huynh le 16 Fév 2022
This is a snippet of part of my file.
In order to read the table starting from the i-th column you can do the following
i=4; %you can change here the row from which you'd like to start reading the file
options=detectImportOptions(filename, 'NumHeaderLines',i);
Table=readtable(filename,opts); %read the table
Then I don't know how to convert the 3 velocities + time into a frequency, do you have an equation to do so or something?
I think I may have to use Fourier Transformation.
Importing the file isn't something that I have an issue with, it's just extracting from specific columns that I'm having an issue doing successfully.
I'm only trying to convert one of the velocities + time into a frequency, there's just three because that's how I recorded that data.
So far I have:
time_seconds = csvread('filename.csv', 2, 1)
But that is giving me ALL of the data in my excel file starting at row 2 instead of just row 2 and column one.
Hence, you need only the vector v0? Right?
Julie Huynh
Julie Huynh le 16 Fév 2022
Modifié(e) : Julie Huynh le 16 Fév 2022
Yes! But now I got it to extract data from the two columns I need, now I just need to figure out how to use those two columns to generate a frequency plot.
filename = 'filename.csv'; %for simiplicity reasons, I omitted row one from the csv file
time_seconds = xlsread(filename, 'A:A');
v0 = xlsread(filename, 'B:B');
Not sure what you mean by convert velocities to frequencies but regarding bringing the data into MATLAB I would suggest in general you are better off using MATLAB's readtable function. You can get details on using that by typing doc readtable on the command line. This will give you the data in a table and you can get individual columns using the column names using dot notation. So for example
dat = reatable('myfile.csv')
vBar = mean(dat.v0); % for example compute the mean of the column named v0
If your column names are not valid MATLAB variable names then they will by default automatically renamed, so for example spaces in the names will be given underscores.

Connectez-vous pour commenter.

 Réponse acceptée

Benjamin Thompson
Benjamin Thompson le 16 Fév 2022
Modifié(e) : Benjamin Thompson le 16 Fév 2022
The function for the discrete fast fourier transform in MATLAB is fft. Typically you will subtract the mean value from the signal and then do the FFT. The result is a complex-valued vector, with each entry corresponding to a 1/N frequency bin. If you are only interested in the magnitude of frequency response use the function abs on the result. Due to the Nyquist limit, the second half of the results will be a mirror image of the first half, and the mid-point of the output of the FFT will correspond to the Nyquist frequency (half the sample rate).
The signal processing toolbox also has the spectrogram function and the signalAnalyzer tool which may be easier to use in the beginning.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by