In: Computer Science
*MATLAB*
Ch8E23
Design a nested struct to store information on constellations for a rocket design company. Each structure should store the constellation's name and information on the stars in the constellation. The structure for the star information should include the star's name, core temperature, distance from the sun, and whether it is a binary star or not. Create variables and sample data for your data structure.
Matlab code:
rocket1.consname='Rocket 1'; %first variable of rocket1
rocket1.information.starname='Star 1';
rocket1.information.coretemp=12000;
rocket1.information.dist=3000;
rocket1.information.bin='yes';
rocket2.consname='Rocket 2'; %first variable of rocket2
rocket2.information.starname='Star 2';
rocket2.information.coretemp=13000;
rocket2.information.dist=3500;
rocket2.information.bin='no';
disp(rocket1)
disp(rocket2)
Screenshot:
Output:
If you have any queries, please comment below.
Please upvote , if you like this answer.