%Create 2D model using EIDORS of matlab.

조회 수: 24 (최근 30일)
priya h
priya h 2021년 2월 27일
답변: Rishav 2024년 4월 22일
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
Jan
Jan 2021년 2월 27일
Please explain "But its not working" with any details.
Jiaxiang
Jiaxiang 2022년 12월 5일
Note mat_idx does not work in 2D. Netgen does not provide it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Rishav
Rishav 2024년 4월 22일
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

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by