Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shopping_cart = struct("apples", 5, "watermelons", 44, "store", "Walmart");
- % You can reference struct fields in the same way you do in C
- % Should display "Walmart"
- disp(shopping_cart.store);
- % Should display 5
- disp(shopping_cart.apples);
- % You can add new fields to an existing struct the same way you would in JS with dictionaries. The line of code below adds a field called "beans"
- shopping_cart.beans = 190;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement