Clear Filters
Clear Filters

I want to avarage the parameters in three dataset

2 views (last 30 days)
I have three datasets contanis the same parameters and with the same length. I want to avarage the paramters to put it into one dataset.
  1 Comment
dpb
dpb on 31 Aug 2023
Need to know what, specifically, you mean by "dataset" and "parameter" in MATLAB nomenclature -- an array, a table, a cell array, ...?
It's always far more likely to get a useful answer if the Question includes sample data that illustrates the problem that folks can see/use instead of having to guess and/or make up sample data that may not be what are talking about, anyway.
On the off chance "dataset" is a 2D array and "parameter" is a given row or column in the array, then load each set into a plane of a 3D array and call mean with the optional DIM argument over the third dimension--in other words average over the planes.

Sign in to comment.

Answers (1)

Riya
Riya on 1 Sep 2023
Hello Basma Eldosouky,
As per my understanding, you want to average the three datasets of same length, which have same parameters.
Please note that, to average the parameters from three datasets and create a new dataset with the averaged values, you can follow these steps in MATLAB:
  • Assuming you have three datasets named dataset1, dataset2, and dataset3, each containing the same parameters and with the same length, you can create a new dataset to store the averaged values:
averaged_dataset = [];
  • Iterate over the indices of the datasets using a “for” loop:
for i = 1:length(dataset1)
% Calculate the average of the parameters at each index
averaged_params = (dataset1(i) + dataset2(i) + dataset3(i)) / 3;
% Append the averaged parameters to the new dataset
averaged_dataset = [averaged_dataset, averaged_params];
end
  • Now, ‘averaged_dataset’ will contain the averaged values of the parameters from the three datasets.
Please note that, the datasets have the same length and are stored in appropriate data structures such as arrays or matrices. Adjust the code accordingly if your datasets are stored differently.
In case you further require a more specific solution tailored to your case, you can provide more information about the format of your datasets or share an example of the data.
I hope it helps!

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!