I am trying to find the location of a point in a mesh using the following code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Generate mesh
xsize = 10; % width of the region [mm]
ysize = 10; % height of the region [mm]
dh = 0.05; % discretisation size [mm]
vmcmesh = createRectangularMesh(xsize, ysize, dh);
% create a point source at location (0,4)
srcloc = findElements(vmcmesh,'location',[0 4]);
vmcboundary.lightsource(srcloc) = {'isotropic'};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I get the following error in matlab
Error using -
Matrix dimensions must agree.
Error in findElements>findElementsNearest (line 209)
m=(pos - locations(ii,:)) .^2;
Error in findElements (line 54)
elements = findElementsNearest(vmcmesh, varargin{1});
I think this is because the variable 'pos' is of size Number of elements X 2, while 'locations(ii,:)' is of size 1X2.
I tried to modify it to
temp = [locations(ii,1)ones(Nel,1), locations(ii,1)ones(Nel,2) ];
m = (pos - temp).^2;
'temp' is a variable containing "No of elements" copies of ii th location. There is a similar error in findBoundaries too.
I am trying to find the location of a point in a mesh using the following code: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Generate mesh xsize = 10; % width of the region [mm] ysize = 10; % height of the region [mm] dh = 0.05; % discretisation size [mm] vmcmesh = createRectangularMesh(xsize, ysize, dh); % create a point source at location (0,4) srcloc = findElements(vmcmesh,'location',[0 4]); vmcboundary.lightsource(srcloc) = {'isotropic'}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I get the following error in matlab
Error using - Matrix dimensions must agree.
Error in findElements>findElementsNearest (line 209) m=(pos - locations(ii,:)) .^2;
Error in findElements (line 54) elements = findElementsNearest(vmcmesh, varargin{1});
I think this is because the variable 'pos' is of size Number of elements X 2, while 'locations(ii,:)' is of size 1X2. I tried to modify it to temp = [locations(ii,1)ones(Nel,1), locations(ii,1)ones(Nel,2) ]; m = (pos - temp).^2;
'temp' is a variable containing "No of elements" copies of ii th location. There is a similar error in findBoundaries too.