How is it possible to plot the average of a vector that has a different size in each iteration?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I'm trying to obtain a plot of M by averaging 10 simulations of M, but the problem is that it has a different size in each run.
Of course I'm getting this error message:
Unable to perform assignment because the size of the left side is 1-by-17 and the size of the right side is 1-by-15
for jj = 1:10
[G_dmg,G_orig, M,L_fail,overLoad,b] = Load_initial(G,5,0,460,1010,600,1000);
t = 2;
while M(t-1)- M(t)~=0
[G_dmg,M,b] = Load_Stages(G_dmg,L_fail,M,b,25);
t = t+1;
end
Mavg(jj,:)=M;
end
Mavg = mean(Mavg,1);
figure(1)
plot(1:length(Mavg(1:end-1)),Mavg(1:end-1));
Thank you.
0 Commenti
Risposta accettata
KSSV
il 3 Giu 2021
Mavg = zeros(10,1) ;
for jj = 1:10
[G_dmg,G_orig, M,L_fail,overLoad,b] = Load_initial(G,5,0,460,1010,600,1000);
t = 2;
while M(t-1)- M(t)~=0
[G_dmg,M,b] = Load_Stages(G_dmg,L_fail,M,b,25);
t = t+1;
end
Mavg(jj)=mean(M);
end
plot(Mavg)
11 Commenti
Più risposte (1)
SALAH ALRABEEI
il 5 Giu 2021
Finding the minimum length ( assum it is 10) , then use the moving average ( smoothing) all the other results to get all of them with same length (10). In short, shorten all the arrays to one fixed length by averaging them using smooth function.
0 Commenti
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots 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!