Array of Create a function called CreateArrayOfStructure to create an array of structs called pizzasinStore with 3 field
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Array of Create a function called CreateArrayOfStructure to create an array of structs called pizzasinStore with 3 field
ans = "Ham, cheese, bacon" >> pizzasInStore.calories ans = ans = ans = 30 3 Function 4 25 5 1 function pizzasInStore= CreateArrayOfStructure (numberCalofBBQ) 2 **** Barbecue pizza, the ingredients are Beef, chicken, bacon, barbecue sauce .. and the calories equals an integer variable. Carbonara pizza, the ingredients are Mushrooms, onion, creamy sauce... and the calories equals 5 calories less that the Barbecue pizza. 30 6 N Save C Reset P % Ham and Cheese pizza, the ingredients are Ham, cheese, bacon... N and the calories equals that of the Barbecue pizza pizzasInStore=struct 9 pizza_name=('Barbecue', 'Carbonara', 'Ham and Cheese'); 10 pizza ingredients=('Beef, chicken, bacon, barbecue sauce', 'Mushrooms, onion, creamy sauce', 'Ham, cheese, b 11 pizza_calories= [numberCalofBBQ, numberCalofBBQ-5, numberCalofBBQ]; 12 13 for i=1: numel(pizza_calories) 14 15 16 17 end 18 end 19 MATLAB Documentation. pizzasInStore (1).name=string(pizza_name(i)); pizzasInStore (1).ingredients string(pizza_ingredients(i)); pizzasInStore(i). calories-pizza_calories (i);
Assessment: 3 of 4 Tests Passed (75%) Check the array of struct is correctly initialized. Variable output has an incorrect value. The struct is not initialized correctly. Check a string datatype is used for the field name. Check a string datatype is used for the field ingredients. Check a numeric datatype is used for the field calories. How was this section? Provide feedback Submit 0% (25%) (25%) 25% (25%) 25% (25%) Total: 75% Feedback?