Time series data in excel

4 次查看(过去 30 天)
Alizah Rahemtulla
Alizah Rahemtulla 2011-11-17
Hi There, I have decided to use matlab instead of excel in order to make my data analysis life easier.
I have several excel files which have, for example, time (s) in column A and concentration in column B.
I've been able to import the excel file and create a plot for all the data (concentration vs time). What I need is to break up the plot into different time periods (100s,150,150....150).
For example: column A: 0-100s, 101-150s, 151-300s.. etc. and find the average concentration(column B) for that time period only so I can plot avg concentration per specified time interval.
Unfortunately it is not a simple matter of using the cell count because some data have been collected twice in 1 second, and sometimes, no data was collected for several seconds.
Any advice would be much appreciated.
Thanks in advance to all!!
Alizah
  2 个评论
Fangjun Jiang
Fangjun Jiang 2011-11-17
So in that case, what is your algorithm to calculate the average? Are you asking for the algorithm, or are you asking how to implement the algorithm, which you didn't disclose.
Alizah Rahemtulla
Alizah Rahemtulla 2011-11-17
Thanks for your comment,
Let me clarify: Once I have the cell numbers I need, I will do something like this:
a1 = nanmean(A(1:n,10));
a2 = nanmean(A(1:n,10)); (concentration values are in column 10)
a11 = ..
Etc.. ( I will have between 8-11 depending on the file)
Then I will use something like:
P = [a1, a2, a3, a4, a5, a6, a7, a8,...]
plot(P)
I know its not very elegant, and I will have to change the number of a#'s each time (because each file is different) but I'm okay with that as I'm a matlab newbie.
I look forward to your insights
Thanks again!

请先登录,再进行评论。

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2011-11-17
Okay, maybe this is what you need.
1. You may want to get rid of the duplicated time and its data.
A=[1 0.1;1 0.2;2 0.3;2 0.4;3 0.5]
[trash,ind]=unique(A(:,1));
A=A(ind,:)
2. You can use logic indexing to pick out the data that meets your time criteria.
A=[(0:20)',rand(21,1)]
ind=and(5<A,A<15);
A=A(ind,:)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by