How to save all the simulated iterations (output of loop) togather?
Ältere Kommentare anzeigen
Hi,
This is my code and each and five out parameters are vp0, vs0, rh0, qp0, qs0 each of size (115*50). I want to save out put vp0, vs0, rh0, qp0, qs0 as of size (115 50) but instead each time I have to change k as from 1 then 2, 3 and so on...
Simply means, each time I have to save individual vp0(1), vp0(2), vp0(3) and so on... How I can save vp0(115*5) all togather?
figure(3);
for k=1:50
print k
msim = mvnrnd(Mu_m, Sigma_m)';
msimlogs = reshape(msim,nt,5);
h1=subplot(1,5,1); hold on; plot(msimlogs(:,1),t); hold on; plot(vp0,t,'k','LineWidth',1.5); title('Simulated V_P'); ylim([1852 1965]);
h2=subplot(1,5,2); hold on; plot(msimlogs(:,2),t); hold on; plot(vs0,t,'k','LineWidth',1.5); title('Simulated V_S'); ylim([1852 1965]);
h3=subplot(1,5,3); hold on; plot(msimlogs(:,3),t); hold on; plot(rho0,t,'k','LineWidth',1.5); title('Simulated Rho'); ylim([1852 1965]);
h4=subplot(1,5,4); hold on; plot(msimlogs(:,4),t); hold on; plot(qp0,t,'k','LineWidth',1.5); title('Simulated Q_P'); ylim([1852 1965]);
h5=subplot(1,5,5); hold on; plot(msimlogs(:,5),t); hold on; plot(qs0,t,'k','LineWidth',1.5); title('Simulated Q_S'); ylim([1852 1965]);
msimsave(:,:,k) = msimlogs;
end
set(h1,'YDir','Rev'); set(h2,'YDir','Rev'); set(h3,'YDir','Rev'); set(h4,'YDir','Rev'); set(h5,'YDir','Rev');
vp0 = msimsave(:,1,3); vs0 = msimsave(:,2,3); rho0 = msimsave(:,3,3); (can I get here all k, instead 1 array)
qp0 = msimsave(:,4,3); qs0 = msimsave(:,5,3);
save Initial_model.mat vp0 vs0 rho0 qp0 qs0;
k --- is plotted below

Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!