Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.42 KB | None | 0 0
  1. shopping_cart = struct("apples", 5, "watermelons", 44, "store", "Walmart");
  2.  
  3. % You can reference struct fields in the same way you do in C
  4.  
  5. % Should display "Walmart"
  6. disp(shopping_cart.store);
  7.  
  8. % Should display 5
  9. disp(shopping_cart.apples);
  10.  
  11. % 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"
  12. shopping_cart.beans = 190;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement