using one line of code, build a matrix that models an airplane in matlab

To build a matrix that models an airplane in MATLAB using one line of code, you can use the following code:

main.m
A = [zeros(1,5), ones(1,15), zeros(1,5);
     zeros(5,25);
     zeros(2,7), ones(2,1), zeros(2,11), ones(2,1), zeros(2,4);
     zeros(2,7), ones(2,3), zeros(2,3), ones(2,3), zeros(2,7);
     ones(1,7), zeros(1,5), ones(1,3), zeros(1,5), ones(1,5);
     ones(1,7), zeros(1,5), ones(1,3), zeros(1,5), ones(1,5);
     ones(1,7), zeros(1,5), ones(1,3), zeros(1,5), ones(1,5);
     ones(1,7), zeros(1,5), ones(1,3), zeros(1,5), ones(1,5);
     zeros(7,25);
     ones(1,5), zeros(1,3), ones(1,5), zeros(1,3), ones(1,7);
     ones(1,5), zeros(1,3), ones(1,5), zeros(1,3), ones(1,7);
     ones(1,5), zeros(1,3), ones(1,5), zeros(1,3), ones(1,7);
     ones(1,5), zeros(1,3), ones(1,5), zeros(1,3), ones(1,7)];
701 chars
14 lines

This code creates a matrix A where ones represent the shape of the airplane and zeros represent the empty space. The arrangement of ones and zeros can be adjusted to create different airplane shapes.

related categories

gistlibby LogSnag