How to create an array/card bank to add elements into later and be empty at the start
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm coding the game no thanks, one of the main parts of the game is for a user to be able to pick up a card and hold it in their hand, I need to display the cards in their hand/array at the beginning of each turn but only the non zero elements. Also add an element each time they decide to pick up a card is there a way to do this? Thanks,
0 comentarios
Respuestas (1)
the cyclist
el 24 de Nov. de 2018
Yes, there is a way to do this. (I am tempted to stop there, because that was your question.)
It's not very clear what sort of information you want to store, which would determine the programmer's choice of data type. It could be a cell array, or maybe just a plan double.
You can initialize an empty cell array as
hand = cell(1,7)
Depending on how you handle future manipulations, it might be handy to start with a 1xN vector of NaN values.
hand = nan(1,7)
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!