%Create 2D model using EIDORS of matlab.

11 visualizzazioni (ultimi 30 giorni)
priya h
priya h il 27 Feb 2021
Risposto: Rishav il 22 Apr 2024
I am using EIDORS. I want to create thousands of images using for loop just by changing the position and conductivity of the object. But its not working.
Nel=16;
stim=mk_stim_patterns(Nel,1,'{ad}','{ad}',{'no_meas_current'},0.01);
%Create 2D model
my1=[0.01,0.015,0.02];
my2=0.02;
for i=1:length(my1)
extra ={'ball','solid ball = cylinder(-0.02,0.02,0.02;-0.025,0.025,1.2;my2) and orthobrick(-1,-1,0;1,1,0.05);'};
extra ={'ball','solid ball = cylinder(-0.02,0.02,0.02;-0.025,0.025,1.2;my1(i)) and orthobrick(-1,-1,0;1,1,0.05);'};
fmdl= ng_mk_cyl_models([0,0.06,0.006],[16],[0.0065,0,0.001],extra); fmdl.stimulation= stim; img2 = mk_image(fmdl,7*10^-3); img2.elem_data(fmdl.mat_idx{2})=10^-16; img2.elem_data(fmdl.mat_idx{2})=5.96*10^7; vi = fwd_solve(img2); vi.meas figure %subplot(232) show_fem(img2,[1,1]);
end
  2 Commenti
Jan
Jan il 27 Feb 2021
Please explain "But its not working" with any details.
Jiaxiang
Jiaxiang il 5 Dic 2022
Note mat_idx does not work in 2D. Netgen does not provide it.

Accedi per commentare.

Risposte (1)

Rishav
Rishav il 22 Apr 2024
Hi priya,
To correctly interpolate 'my1(i)' into the string defining your object, you will need to use string concatenation or 'sprintf' for constructing the string with the variable value.
Please refer to the code below to know how you can modify your loop to correctly change the position or property of the object:
Nel = 16;
stim = mk_stim_patterns(Nel, 1, '{ad}', '{ad}', {'no_meas_current'}, 0.01);
% Conductivity values
my1 = [0.01, 0.015, 0.02];
my2 = 0.02;
for i = 1:length(my1)
% Construct the extra definition string with my1(i) using sprintf
extra_def = sprintf('ball','solid ball = cylinder(-0.02,0.02,0.02;-0.025,0.025,1.2;%f) and orthobrick(-1,-1,0;1,1,0.05);', my1(i));
extra = {'ball', extra_def};
% Create 2D model
fmdl = ng_mk_cyl_models([0, 0.06, 0.006], [16], [0.0065, 0, 0.001], extra);
fmdl.stimulation = stim;
img2 = mk_image(fmdl, 7*10^-3);
% Since mat_idx does not work in 2D, you might need to manually identify
% the elements that belong to your object and set their conductivity
% This part of the code would need customization based on your object's location
img2.elem_data(:) = 10^-16; % Background conductivity
% You need to define how to select elements for the object
% For example, if you had a way to identify the object's elements, it might look like:
% obj_elems = find_object_elements(fmdl, ...); % This is a placeholder for actual logic
% img2.elem_data(obj_elems) = 5.96*10^7; % Object conductivity
vi = fwd_solve(img2);
figure; show_fem(img2, [1, 1]);
end

Categorie

Scopri di più su Handle Classes 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!

Translated by