Application of Logical operators
Mostrar comentarios más antiguos
Hi team,
I am trying to assign a colour to each part of this simple warehouse diagram with 4 shelves.

I have to assign a unique value to each part of this model, i.e., for the 4 shelves location, the aisles location, the warehouse corners.
I have tried to use logical operators to assign a colour to each part of the warehouse model. But I am having issues to do that properly. Kindly help.
My code:
clc;
clear all;
close all;
x_pos_tmp = 0:0.05:10;
y_pos_tmp = 0:0.05:5;
x_pos = repelem(x_pos_tmp,1,length(y_pos_tmp))';
y_pos = repmat(y_pos_tmp,1,length(x_pos_tmp))';
mat = [x_pos y_pos];
%% Shelf distance column
tmp1 = zeros(1,length(mat))';
matTmp = [mat tmp1];
for nx=1:length(mat)
% Adding the data for within shelf coverage
if ((mat(nx,1)>=1.1 && matTmp(nx,1)<=1.9)&&(matTmp(nx,2)>=1.1 && matTmp(nx,2)<=3.9))
matTmp(nx,3) = 50;
elseif ((matTmp(nx,1)>=3.1 && matTmp(nx,1)<=3.9)&&(matTmp(nx,2)>=1.1 && matTmp(nx,2)<=3.9))
matTmp(nx,3) = 50;
elseif ((matTmp(nx,1)>=5.1 && matTmp(nx,1)<=5.9)&&(matTmp(nx,2)>=1.1 && matTmp(nx,2)<=3.9))
matTmp(nx,3) = 50;
elseif ((matTmp(nx,1)>=7.1 && matTmp(nx,1)<=7.9)&&(matTmp(nx,2)>=1.1 && matTmp(nx,2)<=3.9))
matTmp(nx,3) = 50;
% In the aisle coverage
elseif ((matTmp(nx,1)>=2.1 && matTmp(nx,1)<=2.9)&&(matTmp(nx,2)>=1.1 && matTmp(nx,2)<=3.9))
% matTmp(nx,3) = min((matTmp(nx,1)-2),(3-matTmp(nx,1)));
matTmp(nx,3) = 100;
elseif ((matTmp(nx,1)>=4.1 && matTmp(nx,1)<=4.9)&&(matTmp(nx,2)>=1.1 && matTmp(nx,2)<=3.9))
% matTmp(nx,3) = min((matTmp(nx,1)-4),(5-matTmp(nx,1)));
matTmp(nx,3) = 100;
elseif ((matTmp(nx,1)>=6.1 && matTmp(nx,1)<=6.9)&&(matTmp(nx,2)>=1.1 && matTmp(nx,2)<=3.9))
% matTmp(nx,3) = min((matTmp(nx,1)-6),(7-matTmp(nx,1)));
matTmp(nx,3) = 100;
% Corner Aisles data
elseif ((matTmp(nx,1)>=0 && matTmp(nx,1)<=0.9)&&(matTmp(nx,2)>=0 && matTmp(nx,2)<=5)) % Left corner aisle
% matTmp(nx,3) = 1-matTmp(nx,1);
matTmp(nx,3) = 150;
elseif ((matTmp(nx,1)>=7.9 && matTmp(nx,1)<=10)&&(matTmp(nx,2)>=0 && matTmp(nx,2)<=5)) % Right corner aisle
% matTmp(nx,3) = matTmp(nx,1)-8;
matTmp(nx,3) = 150;
% Strong LOS cases (East-West Direction)
elseif ((matTmp(nx,1)>=1.1 && matTmp(nx,1)<=7.9)&&(matTmp(nx,2)>=0 && matTmp(nx,2)<=0.9))
% matTmp(nx,3) = min((matTmp(nx,2)-0),(1-matTmp(nx,1)));
matTmp(nx,3) = 200;
elseif ((matTmp(nx,1)>=1.1 && matTmp(nx,1)<=7.9)&&((matTmp(nx,2)>=4.1 && matTmp(nx,2)<=5)))
% matTmp(nx,3) = min((matTmp(nx,2)-4),(5-matTmp(nx,1)));
matTmp(nx,3) = 200;
else
matTmp(nx,3) = 0;
end
end
%% Plot
data = reshape(matTmp(:,3),length(x_pos_tmp),length(y_pos_tmp));
figure(1)
set(gca,'DefaultTextFontSize',14)
imagesc(0:10,0:5, data); % 0:0.5:18,0:0.1:30,
xlabel('X-distance [m]','FontSize',14);
ylabel('Y-distance [m]','FontSize',14);
set(gca,'YDir','normal');
a=colorbar;
% a.Label.String = 'SINR [dB]';
ylabel(a,'SINR [dB]','FontSize',14)
colormap jet;
% clim([20 90])
--------------------------------------------------------------------------------------------------------------------------------------------------------
Output:

This plot should look like the first figure. Looking forward to any kind of suggestions.
Thank You,
Rahul Singh Gulia
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
