Different data processing depending on the spatial region of the points

2 次查看(过去 30 天)
Dear all
I am currently dealing with the data treatment associated to the following geometry:
for which the following code has been used:
x=200; % nm
y=97.0313588850174; % nm
%% Let's upload the geometry files
geometry_layers={'Tetralayer' 'Pentalayer' 'Hexalayer'};
num_geo=dir(strcat(pwd,'\Double-Anisotropy\Zero-Field-Cooling\Without-Field\Fifth-Seed\Dipolar-Tensorial\Geometry_*.geo'));
for i=1:length(num_geo)
geo_files{i}=dlmread(strcat(pwd,'\Double-Anisotropy\Zero-Field-Cooling\Without-Field\Fifth-Seed\Dipolar-Tensorial\Geometry_',geometry_layers{i},'.geo'),'',1,0);
end
clear geometry_layers num_geo
for i=1:length(geo_files)
if i==1
geometry_tetra=cell2mat(geo_files(i));
geometry_tetra(:,1)=geometry_tetra(:,1).*x; % nm
geometry_tetra(:,2)=geometry_tetra(:,2).*y; % nm
elseif i==2
geometry_penta=cell2mat(geo_files(i));
geometry_penta(:,1)=geometry_penta(:,1).*x; % nm
geometry_penta(:,2)=geometry_penta(:,2).*y; % nm
elseif i==3
geometry_hexa=cell2mat(geo_files(i));
geometry_hexa(:,1)=geometry_hexa(:,1).*x; % nm
geometry_hexa(:,2)=geometry_hexa(:,2).*y; % nm
end
end
geometry_tetra(end+1,:)=geometry_tetra(1,:); % nm
geometry_penta(end+1,:)=geometry_penta(1,:); % nm
geometry_hexa(end+1,:)=geometry_hexa(1,:); % nm
clear geo_files
%% Let's define the text string
top_4L_vortices=[geometry_tetra(1,:); geometry_penta(7,:); geometry_penta(8,:); geometry_penta(1,:)]; % nm
[top_4L_position(1),top_4L_position(2)]=centroid(polyshape(top_4L_vortices)); % nm
bottom_4L_vortices=[geometry_tetra(5,:); geometry_tetra(4,:); geometry_penta(4,:); geometry_tetra(6,:)]; % nm
[bottom_4L_position(1),bottom_4L_position(2)]=centroid(polyshape(bottom_4L_vortices)); % nm
top_5L_vortices=[geometry_penta(1,:); geometry_penta(8,:); geometry_hexa(2,:); geometry_penta(2,:)]; % nm
[top_5L_position(1),top_5L_position(2)]=centroid(polyshape(top_5L_vortices)); % nm
bottom_5L_vortices=[geometry_penta(5,:); geometry_penta(4,:); geometry_hexa(4,:); geometry_tetra(8,:)]; % nm
[bottom_5L_position(1),bottom_5L_position(2)]=centroid(polyshape(bottom_5L_vortices)); % nm
unique_6L_vortices=[geometry_hexa(1,:); geometry_hexa(4,:); geometry_hexa(3,:); geometry_hexa(2,:)]; % nm
[unique_6L_position(1),unique_6L_position(2)]=centroid(polyshape(unique_6L_vortices)); % nm
clear top_4L_vortices bottom_4L_vortices top_5L_vortices bottom_5L_vortices unique_6L_vortices
%% Let's do the figure
u1=figure(1)
plot(geometry_tetra(:,1),geometry_tetra(:,2),'-k','LineWidth',0.5);
hold on
plot(geometry_penta(:,1),geometry_penta(:,2),'-k','LineWidth',0.5);
plot(geometry_hexa(:,1),geometry_hexa(:,2),'-k','LineWidth',0.5);
text(top_4L_position(1),top_4L_position(2),'4L','HorizontalAlignment','center','VerticalAlignment','middle','FontSize',18,'interpreter','latex');
text(bottom_4L_position(1),bottom_4L_position(2),'4L','HorizontalAlignment','center','VerticalAlignment','middle','FontSize',18,'interpreter','latex');
text(top_5L_position(1),top_5L_position(2),'5L','HorizontalAlignment','center','VerticalAlignment','middle','FontSize',18,'interpreter','latex');
text(bottom_5L_position(1),bottom_5L_position(2),'5L','HorizontalAlignment','center','VerticalAlignment','middle','FontSize',18,'interpreter','latex');
text(unique_6L_position(1),unique_6L_position(2),'6L','HorizontalAlignment','center','VerticalAlignment','middle','FontSize',18,'interpreter','latex');
xlim([0 x]);
ylim([0 y]);
pbaspect([x/y 1 1]);
set(gca,'TickLabelInterpreter','latex','FontSize',18);
box on;
where the "Geometry_*.geo" files have been attached in this post in .txt format. Those regions with 4L label over it defines regions with four layers of xy data along the normal direction to the showed plane, those with 5L denotes five layers, and 6L goes for the six layers.
Let's imagine that we have some two-dimensional variables, "mx_1", "mx_2", "mx_3", "mx_4", "mx_5", and "mx_6", where the number denotes its height index, and whose values are defined at each (x,y) set of points. At the height of the fifth and sixth layers in the regions with the "4L" label, the mx variable will be zero (same as at the height of the sixth layer in the regions with the "5L" label). Within the definition regions, the mx variable is, in general, non-zero, but some points with a zero value could be present.
My aim is to perform a height-dependent summation operation at each (x,y) set of points. That it is, in the regions with the label 4L, I want to perform the summation operation (mx_1+mx_2+mx_3+mx_4)/4; for those with 5L, (mx_1+mx_2+mx_3+mx_4+mx_5)/5; and for those with 6L, (mx_1+mx_2+mx_3+mx_4+mx_5+mx_6)/6.
Any ideas on how could I do this?

回答(1 个)

Matt J
Matt J 2024-8-26
Sure. Use inpolygon to detect in which region a given (x,y) point lies and compute the summation of mx variables accordingly.
  1 个评论
Roderick
Roderick 2024-8-28
Hi @Matt J. As you can see in the attached script in this answer, I did so. But for some reason, it does not give a reasonable result according to some other computed variable that does not need the same kind of messy treatment.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by