How to add the rest of parameters (in) loop?
2 views (last 30 days)
Show older comments
Hi everyone,
I have copied here my code and data as well (attached). The data comprises on 5 parameters (vp0 vs0 rho0 qp0 qs0). I have a a loop for first parameter (vp0) and want to add rest of four parameters in the loop as well. How I can add them in a single loop?
And how then I can save them as well for the next code?
load Initial_model.mat vp0 vs0 rho0 qp0 qs0;
load t.mat t; t=t';
pert_vp0 = -250 + 500 * rand(size(vp0));
pert_vs0 = -250 + 500 * rand(size(vs0));
pert_rho0 = -25 + 50 * rand(size(vs0));
pert_qp0 = -10 + 20 * rand(size(vs0));
pert_qs0 = -5 + 10 * rand(size(vs0));
pertvp0_smooth = vel_smoother(pert_vp0, 128, .1, 1);
min_vp0 = min(pertvp0_smooth);
max_vp0 = max(pertvp0_smooth);
minrange_vp0 = -200;
maxrange_vp0 = 250;
pertvp0_smooth = (pertvp0_smooth - min_vp0)*((maxrange_vp0-minrange_vp0)/(max_vp0-min_vp0)) + minrange_vp0;
figure, plot(pert_vp0,t); ylim([1700 1960]); set(gca,'ydir','reverse');
hold on, plot(pertvp0_smooth,t);ylim([1700 1960]); set(gcf,'position',[900 285 200 550]);
num = 50;
models=zeros(260,num);
for i=1:num
pert_vp0 = -100 + 200 * rand(size(vp0));
pertvp0_smooth = vel_smoother(pert_vp0, 128, .1, 1);
min_vp0 = min(pertvp0_smooth);
max_vp0 = max(pertvp0_smooth);
pertvp0_smooth = (pertvp0_smooth - min_vp0)*((maxrange_vp0-minrange_vp0)/(max_vp0-min_vp0)) + minrange_vp0;
models(:,i) = vp0 + pertvp0_smooth;
end
figure, plot(models,t);
hold on, plot(mean(models,2),t, 'k', 'linewidth', 3);
set(gca,'ydir','reverse'); ylim([1700 1960]); set(gcf, 'position', [700 285 200 550]);
3 Comments
Mathieu NOE
on 21 Apr 2022
hello
ok this is solved
next issue :
Unrecognized function or variable 'vel_smoother'.
Error in nisar2 (line 12)
pertvp0_smooth = vel_smoother(pert_vp0, 128, .1, 1);
Answers (0)
See Also
Categories
Find more on Elementary Math in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!