Aircraft center of gravity, moving passengers one by one

1 view (last 30 days)
Hi guys,
It's me again and I have the following code which I received a lot of help from here.
airlinerows = 30;
airlinehalfsideseats = 3;
occupacyfactor = 0.85;
rightside = double(rand(airlinerows,airlinehalfsideseats) < occupacyfactor);
%sum(sum(rightside))
%rightside
middleasile = double(zeros(30,1));
leftside = double(rand(airlinerows,airlinehalfsideseats) < occupacyfactor);
passengermap = [leftside,middleasile,rightside];
[rows,columns] = size(passengermap);
passengerweights = double(50 + 30*(rand(size(passengermap))));
luggageweights = double(5 + 2*(rand(size(passengermap))));
passengerweights = passengerweights.*passengermap
luggageweights = luggageweights.*passengermap
xcogattime = zeros(180,1);
ycogattime = zeros(180,1);
%passengerweights
timepoint = 1;
for row = 1 : rows
% First assume that the left side empties first.
% Start with seat 3, then 2, then 1
for col = 3 : -1 : 1
%passengermap(row, 3) = 0; % Empty the aisle seat only
% Remaining passengers shift to the right
% After the aisle passenger has left, and remaining passengers has shifted right
passengermap(row, 3) = passengermap(row,2);
passengermap(row, 2) = passengermap(row,1);
passengermap(row, 1) = 0.0;
passengerweights(row, 3) = passengerweights(row,2);
passengerweights(row, 2) = passengerweights(row,1);
passengerweights(row, 1) = 0.0;
luggageweights(row, 3) = passengerweights(row,2);
luggageweights(row, 2) = passengerweights(row,1);
luggageweights(row, 1) = 0.0;
% Update passenger weight and luggage weight.
passengerweights = passengerweights .* passengermap;
luggageweights = luggageweights .* passengermap;
% fprintf(fileID,passengermap);
%re-compute center of gravity.
xcogattime(timepoint) = findxcog(passengermap,passengerweights, luggageweights);
ycogattime(timepoint) = findycog(passengermap,passengerweights, luggageweights);
timepoint = timepoint + 1;
end
% Now empty the right side.
% Start with seat in column 5, then 6, and then finally 7
for col = 5 : 7
%passengermap(row, 5) = 0; % Empty the aisle seat only
% Remaining passengers shift to the right
% After the aisle passenger has left, and remaining passengers has shifted right
passengermap(row, 5) = passengermap(row,6);
passengermap(row, 6) = passengermap(row,7);
passengermap(row, 7) = 0.0;
passengerweights(row, 5) = passengerweights(row,6);
passengerweights(row, 6) = passengerweights(row,7);
passengerweights(row, 7) = 0.0;
luggageweights(row, 5) = passengerweights(row,6);
luggageweights(row, 6) = passengerweights(row,7);
luggageweights(row, 7) = 0.0;
% Update passenger weight and luggage weight.
passengerweights = passengerweights .* passengermap;
% fprintf(fileID,passengermap);
luggageWeights = luggageweights .* passengermap;
%re-compute center of gravity.= findcog(passengerMap,passengerWeights, luggageWeights);
x = findxcog(passengermap,passengerweights, luggageweights);
xcogattime(timepoint) = x;
y = findycog(passengermap,passengerweights, luggageweights);
ycogattime(timepoint) = y;
timepoint = timepoint + 1;
end
end
for i = 1:180
S=sprintf('(X,Y) Coord of COG at timepoint %i are: (%f , %f)\n',i,round(xcogattime(i),3),round(ycogattime(i),3));
disp(S);
end
[xcogattime,ycogattime]
%imshow(passengermap);
plot(xcogattime, ycogattime);
when I run the code it gives me the CoG with respect to time. I get the CoG in the x and y-direction but I would like to perform the following:
I would like to move the passengers from the seats into the middle of the aircraft and then out of the aircraft. So the CoG in the y-direction stays around the 15th column.
What do I need to do this code in order to make the passengers get out of their seats and leave one by one?
Any help!!!!!!!!!!!!!!!!!!!

Answers (0)

Categories

Find more on Transmission Applications in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!