Index in position 2 exceeds array bounds (must not exceed 1).

2 views (last 30 days)
Run each section as indicated with hash
##
% Forward solvers $Id: forward_solvers01.m 3790 2013-04-04 15:41:27Z aadler $
% 2D Model
imdl= mk_common_model('d2d1c',19);
% Create an homogeneous image
img_1 = mk_image(imdl);
h1= subplot(221);
show_fem(img_1);
% Add a circular object at 0.2, 0.5
% Calculate element membership in object
img_2 = img_1;
select_fcn = inline('(x-0.2).^2+(y).^2<0.1^2','x','y','z');
img_2.elem_data = 1 + elem_select(img_2.fwd_model, select_fcn);
h2= subplot(222);
show_fem(img_2);
img_2.calc_colours.cb_shrink_move = [.3,.8,-0.02];
common_colourbar([h1,h2],img_2);
##
vh= fwd_solve( img_1 );
vi= fwd_solve( img_2 );
% Add -12dB SNR
vi_n= vi;
nampl= std(vi.meas - vh.meas)*10^(-0/20);
vi_n.meas = vi.meas + nampl *randn(size(vi.meas));
% Compare 2D algorithms
% $Id: tutorial120b.m 5522 2017-06-07 12:03:37Z aadler $
clf;clear imgr imgn
% Create Inverse Model
inv2d= eidors_obj('inv_model', 'EIT inverse');
inv2d.reconst_type= 'difference';
inv2d.jacobian_bkgnd.value= 1;
% This is not an inverse crime; inv_mdl != fwd_mdl
inv2d.fwd_model= imdl.fwd_model;
% Guass-Newton solvers
inv2d.solve= @inv_solve_diff_GN_one_step;
% Tikhonov prior
inv2d.hyperparameter.value = .03;
inv2d.RtR_prior= @prior_tikhonov;
imgr(1)= inv_solve( inv2d, vh, vi);
imgn(1)= inv_solve( inv2d, vh, vi_n);
% NOSER prior
inv2d.hyperparameter.value = .1;
inv2d.RtR_prior= @prior_noser;
imgr(2)= inv_solve( inv2d, vh, vi);
imgn(2)= inv_solve( inv2d, vh, vi_n);
% Laplace image prior
inv2d.hyperparameter.value = .1;
inv2d.RtR_prior= @prior_laplace;
imgr(3)= inv_solve( inv2d, vh, vi);
imgn(3)= inv_solve( inv2d, vh, vi_n);
% Automatic hyperparameter selection
inv2d.hyperparameter = rmfield(inv2d.hyperparameter,'value');
inv2d.hyperparameter.func = @choose_noise_figure;
inv2d.hyperparameter.noise_figure= 0.5;
inv2d.hyperparameter.tgt_elems= 1:4;
inv2d.RtR_prior= @prior_gaussian_HPF;
inv2d.solve= @inv_solve_diff_GN_one_step;
imgr(4)= inv_solve( inv2d, vh, vi);
imgn(4)= inv_solve( inv2d, vh, vi_n);
inv2d.hyperparameter = rmfield(inv2d.hyperparameter,'func');
% Total variation using PDIPM
inv2d.hyperparameter.value = 1e-5;
inv2d.solve= @inv_solve_TV_pdipm;
inv2d.R_prior= @prior_TV;
inv2d.parameters.max_iterations= 10;
inv2d.parameters.term_tolerance= 1e-3;
%Vector of structs, all structs must have exact same (a) fields (b) ordering
imgr5= inv_solve( inv2d, vh, vi);
imgr5=rmfield(imgr5,'type'); imgr5.type='image';
imgr(5)=imgr5;
imgn5= inv_solve( inv2d, vh, vi_n);
imgn5=rmfield(imgn5,'type'); imgn5.type='image';
imgn(5)=imgn5;
% Output image
imgn(1).calc_colours.npoints= 128;
imgr(1).calc_colours.npoints= 128;
show_slices(imgr, [inf,inf,0,1,1]);
print_convert tutorial120b.png;
show_slices(imgn, [inf,inf,0,1,1]);
print_convert tutorial120c.png;
##
% Simulate obj $Id: GREIT_test_params01.m 2167 2010-04-04 21:39:48Z aadler $
fmdl = ng_mk_cyl_models([2,1,0.08],[16,1],[0.05]);
fmdl.stimulation = mk_stim_patterns(16,1,[0,1],[0,1],{},1);
imgs= mk_image( fmdl, 1);
show_fem(imgs);
print_convert('GREIT_test_params01a.png','-density 60');
view(0,0)
xlim([-.4,.4])
zlim(1+[-.4,.4])
print_convert('GREIT_test_params01b.png','-density 60');
% Simulate obj $Id: GREIT_test_params02.m 4823 2015-03-29 15:17:16Z bgrychtol-ipa $
% Specify positions to simulate (only x-axis here)
r = linspace(0,0.9,100);
xyzr = [r; zeros(1,100); ones(1,100)];
% Show GREIT images
opt.noise_figure = 0.5;
i_gr = mk_GREIT_model(fmdl,0.2,[],opt);
imgr = inv_solve(i_gr, vh, vi(:,1:5:100)); ###
I am currently trying to convert from the simulation of 3d object to simulate sequence targets (http://eidors3d.sourceforge.net/tutorial/GREIT/GREIT_test_params.shtml). Only difference is i am using a different value for vh (homogeneous) and vi (in-homogeneous) from other data sources. Upon running the code reaching the last line labeled with 3 hashes i encountered an error as shown in the title.

Answers (1)

Cris LaPierre
Cris LaPierre on 4 Oct 2020
I think the error message is clear on what the issue is. It appears your variable vi has a size of mx1. You are trying to index it using vi(:,1:5:100). Check the size of your variable to see if there are 100 columns of data.

Categories

Find more on Ceramics in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!