store end values of an array in a nexted loop

i have this code below. I do 20 simulations and load them. For every simulation the RRE is 1x5000 (preallocated size). But i only need end values. so i pick them with RRE_MU_R1(end);I want to find the mean of all the end values from the 20 simulations and store them in an array. And all this needs to be repeated for every value of MV.
for MV = .1:.1:.2
for i=1:20
load( ['output/MU_R_',mat_size,'_',int2str(100*MV),'_',int2str(i),'.mat'], 'RRE_MU_R') //load data
RRE_MU_R1=nonzeros(RRE_MU_R); //remove zeros
rRE_MU_R(i) =RRE_MU_R1(end);
end
end

답변 (1개)

madhan ravi
madhan ravi 2018년 10월 22일

0 개 추천

After the loops:
mean(rRE_MU_R)

댓글 수: 3

fadams18
fadams18 2018년 10월 22일
that will work for just 1 value of MV. how to I find the mean(rRE_MU_R) for the other value. so that in the end i put the in a vector to look like data=[mean1,mean2].(I have a lot of mv values so i intend to store the means at one run.) but it give me just one value of mean.
madhan ravi
madhan ravi 2018년 10월 22일
size(rRE_MU_R)?
fadams18
fadams18 2018년 10월 22일
Its 20. so after the mean, i have just one value. then i want to do same for the next value of mv=0.2. because i want to plot a graph of mean(RRE) vs MV values

이 질문은 마감되었습니다.

태그

질문:

2018년 10월 22일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by