Mean of Multiple data sets across a time series
22 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have 5 sets of CO2 concentrations, all taken at different locations. They have different start dates, the earliest beginning in 1957 and the latest in 1981 all up until the present. I would like to find the average of all 5 locations to create one line and be able to plot it against time, I believe this would take a for loop which I am not very experienced in. I also considered keeping the datasets separate and just finding the averages of each and using hold on to plot them against each other, but I again run into the issue of figuring out how to code to loop to keep it against time. If one of these ways would be a better option for how I should analyze my data that would be helpful.
6 Commenti
Voss
il 9 Dic 2021
Yeah, if you can upload the .csv file, that would be perfect.
If you're unable to do so, maybe it's too large? Probably just the top however many rows would be sufficient for me to get an idea of what the data is. If all else fails, maybe a screen shot of the .csv open in Excel or whatever would work well enough.
Risposte (1)
Aman
il 18 Apr 2024
Hi Fiona,
As per my understanding, you want to get the mean CO2 where the reading has been taken at different locations and the time stamp of the recording is also different.
Without the actual data, it is difficult to tell the solution upfront, but I have created a sample example code where I have created a table that contains readings in ppm across different locations and were taken at different months. Now, in order to calculate the mean, I'm getting the reading across the same month and then calculating the mean. You can refer to the below code for your reference.
location = ["A";"A";"B";"B";"B";"C";"C";"D"];
month = ["Jan";"Mar";"Jan";"Feb";"Mar";"Feb";"Mar";"Jan"];
ppm = [10;20;30;40;50;60;70;80];
dataTable = table(location,month,ppm);
dataArray = table2array(dataTable);
uniqueMonths = unique(dataArray(:,2));
for i=1:length(uniqueMonths)
requiredPPM = dataArray(dataArray(:,2)==uniqueMonths(i),3);
monthMean = mean(str2double(requiredPPM));
disp("Mean of " + uniqueMonths(i) + " is " + monthMean);
end
Hope it helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!