As seen in image below, I have a struct of 5 fields. I need to compute the avarege of the HV3, HV5, HV7 and thd in 1st row, then in the second row and so on seperately.. Have a nice weekend..
k here denotes the dimension along which to average. This is not the correct option to use for your case. To average a specific number of elements, try something like this
Ave3 = zeros(size(S));
Ave5 = zeros(size(S));
Ave7 = zeros(size(S));
Avethd = zeros(size(S));
for i=1:length(S)
M3=([S(i).HV3]);
M5=([S(i).HV5]);
M7=([S(i).HV7]);
Mthd = ([S(i).thd]);
Ave3(i)=mean(M3(1660:9870)) ;
Ave5(i)=mean(M5(1660:9870));
Ave7(i)=mean(M7(1660:9870));
Avethd(i)=mean(Mthd(1660:9870));
end
This code also store average values for all the iterations.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
0 Comments
Sign in to comment.