Mean of Multiple Data

Hey, I am a newbie in MATLAB, wanna ask a question: I have a data of frequency (column 1) and the impedance (column 2), and I did multiple measurements, let's say 5 measurements.
I want to plot the graph of the average value of the impedance in each frequency. I tried to find the mean of it, but it turns out that the coding I did find the average of the whole impedance (so i only got 1 average value, it's suppose to be 1 average value for each frequency).
Can somebody help me with the code? I use the .txt files as the data source, by the way.
Thank you for the help.

 Akzeptierte Antwort

Evgeny Pr
Evgeny Pr am 25 Jan. 2013
Bearbeitet: Evgeny Pr am 25 Jan. 2013

1 Stimme

frequency = [1, 2, 3, 4, 5, 6]
impedance = [6 2 7 5 6 7
10 9 5 1 7 9
7 8 4 7 4 3
6 2 4 6 7 2
2 2 10 4 10 11]
meanImpedance = mean(impedance, 1) % Rows - measurements
plot(frequency, meanImpedance)

5 Kommentare

Tesa
Tesa am 25 Jan. 2013
thaks but i have seperated files of impedance. so in first file i have the frequency information and first measurement of impedance. in 2nd file, in 3rd one and so on. I can not use the code you've given. please help
Evgeny Pr
Evgeny Pr am 25 Jan. 2013
Bearbeitet: Evgeny Pr am 25 Jan. 2013
Well it is not that difficult to do :)
For example:
% load_measurement_data - your function for load data from txt file
freqAndImpedance1 = load_measurement_data('measurements1.txt')
freqAndImpedance2 = load_measurement_data('measurements2.txt')
freqAndImpedance3 = load_measurement_data('measurements3.txt')
% only frequences for all measurements
frequency = freqAndImpedance1(:,1);
% all measurements for impedance (Columns - measurements)
impedances = [freqAndImpedance1(:,2), ...
freqAndImpedance2(:,2), ...
freqAndImpedance3(:,2)];
meanImpedance = mean(impedances, 2);
plot(frequency, meanImpedance)
Tesa
Tesa am 25 Jan. 2013
thanks! :D you help a lot :)
Tesa
Tesa am 28 Jan. 2013
I've got the feedback like this: Undefined function 'load_measurement_data' for input arguments of type 'char'. Is there something wrong? Thanks :)
Tesa
Tesa am 28 Jan. 2013
and also, what does this one mean? meanImpedance = mean(impedances, 2); Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by