I am new to matlab. What I am trying to do is to plot the data I recorded from the phone on matlab. The data is looks like this {timestamp, value}.
The timestamp is recorded in millionseconds by calling the Java function System.currentTimeMillis(). Therefore I have two questions actually to plot it on matlab.
How can I transform the timestamp from milliseconds to date format on matlab?
How can I plot the data on matlab, where Y-axis is the value, and X-axis is the date? The graph should look like discrete dots.
Thanks a lot.
To create plots with dates / times on one axis, plot your data, then relabel the axis using datetick
plot(datenum('1-jan-2000'):datenum('10-jan-2000'),[1:10])
datetick('x','dd-mm')
Related
I just want to use any simple seaborn or matplot plot to visualize my data set as a lineplot. Please help. I cant seem to figure out how to plot these values i keep getting all types of errors.
My data set consists of 4 columns, the first is date which I want to plot on my x axis and the rest are numeric values of gold, oil and the dollar that I want to plot.
I have my dates set to datetime value and the rest set to float64, I am trying to plot the fluctuations of oil, gold and the dollar over time to look at any possible correlation. Sorry for any obvious mistakes I am not an expert.
Doing This gives me only one plotted value and the Date values on x axis is incorrect
plt.xlabel('Date')
plt.ylabel('Values')
plt.title('Historical Data')
df['Price_Gold'].plot()
So basically im running into trouble when trying to plot multiple values against time.
df.plot(x='Date', y=['Col1', 'Col2'])
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html
I have to plot a time series data in MATLAB. The Y axis is a parameter taken six hourly for each day in a certain month of the year. And 44 such years have been taken into account. From 1958 to 2001. So the points on the X axis are 4*31*44=5456. How can I plot the data efficiently in MATLAB? The data file has two column vectors.
I have to plot the x axis so that it shows 44 July s from 1958 to 2001 . Each July has 124 points.
One for the time points (5456 points) so 5456 rows and other for the parameter measured. Thanks a lot.
As you don't give any more details, it is hard to know exactly what you are asking. If you have a matrix A with two columns, then you are looking for
plot( A(:,1), A(:,2) )
Alternatively, perhaps you want to see the histogram, hist, or the scatter plot scatter.
Well your X-axis(time data) is most probably not in datetime format & hence the problem.Once that is done, the plot will show what you want. You should try and change it to datetime & then try
plot(X,Y)
or
plot(A(:,1),A(:,2))
whichever be your data format
I used periodogram in Matlab to perform vibration analysis. I wanted to see how the frequencies changed with time during vibration, and I believed I should use waterfall plot or other 3D plot. My question is how I can save the amplitude data from ftt into a matrix (m,n). m is number of the data point from each calculation, n is the number of time interval for each calculation with periodogram.
I learned how to plot waterfall plot or other 3D plot in Matlab, but do not know how to save the amplitude data into a matrix. Did some search, but with no luck.
I am trying to find a way to create a graph that shows an audio wave and its time-frequency data (time on x-axis, wave energy and frequency data on y-axis). I have this code that does it on two separate plots:
[audio, fs] = wavread('audio.wav');
subplot(211)
spectrogram(audio,256,200,256,fs,'yaxis')
subplot(212)
wavEnergy=audio(:,1);
time=(1/fs)*length(wavEnergy);
t=linspace(0,time,length(wavEnergy));
plot(t,wavEnergy);
and now I need help with 2 things.
First, how do I get the spectrogram time to be in terms of seconds? Right now it graphs with an x-range of 0-340 (labeled 'time') and I know the clip is about 40s long (the other plot properly displays this).
Second, how do I plot them together? I know I can get a matrix from spectrogram but which array do I get from that matrix and how do I convert its timeframe to seconds?
EDIT:
First problem solved, but the graphs are still doing something strange - they both output about 40s of data, but the ranges of the graphs and the offsets of the data are different. The spectrogram goes from 0s-40s but the first .5s shows no data, and the wave plot goes from 0s-45s and the last 5s shows no data. How can I get the ranges and offsets to be the same?
EDIT 2:
I just needed to use axis tight; on both subplots
Aligning these two plots on the same time-base relies on determining the sampling frequency of your data. Based on the parameter you are passing to spectrogram, the sampling frequency is 1000 Hz. Based on your definition of time = (1/8000)*length(wavEnergy), the sampling frequency is 8000 Hz. These are not consistent. To get the audio sampling frequency from your wav file you can use [audio, fs] = wavread('audio.wav').
I have four 1xN sound signals and I want to view the average spectra plot like the one given in the link below:
http://i1233.photobucket.com/albums/ff396/sakurayen/Plot/AMaximumLikelihoodApproachtoSinglechannelSourceseparationpdf-AdobeReader.jpg
I've tried to use the MATLAB function , PSD, to plot the spectral but I am getting a different plot instead. Note that the data used for both the plots are the same.
plot obtained using PSD function in MATLAB:
http://i1233.photobucket.com/albums/ff396/sakurayen/Plot/PowerSpectralDensityofRJMF.png
Thanks!