- #1
craigpmorgan
- 8
- 0
Hi all,
I've created a structure containing various fields of data. The data in these fields is stored in matrices and is be added to at regular intervals. I'd like the system to identify the amount of inputs the fields already contain and then extend said matrices to include this new data.
The program concerns the monitoring of plant growth.
The code below works fine but requires the user to know the amount of measurements that have already been input. I'd like to avoid this as it could easily lead to data being overwritten:id = input('Enter plant number: ');
iteration = input('Enter iteration: ');
plant(id).entryDate(iteration) = {date};
plant(id).height(iteration) = [height]; % The variable height is already in the workspace
My idea for ensuring new data is stored in the correct place was to use numel function, something like the following (removing the user-input value of 'it' from above):
previous_iterations = numel(plant(id).height);
it = previous_iterations + 1;
I can't this this or anything similar to work.
Thanks very much for your time, I'd greatly appreciate any help.
Craig
I've created a structure containing various fields of data. The data in these fields is stored in matrices and is be added to at regular intervals. I'd like the system to identify the amount of inputs the fields already contain and then extend said matrices to include this new data.
The program concerns the monitoring of plant growth.
The code below works fine but requires the user to know the amount of measurements that have already been input. I'd like to avoid this as it could easily lead to data being overwritten:id = input('Enter plant number: ');
iteration = input('Enter iteration: ');
plant(id).entryDate(iteration) = {date};
plant(id).height(iteration) = [height]; % The variable height is already in the workspace
My idea for ensuring new data is stored in the correct place was to use numel function, something like the following (removing the user-input value of 'it' from above):
previous_iterations = numel(plant(id).height);
it = previous_iterations + 1;
I can't this this or anything similar to work.
Thanks very much for your time, I'd greatly appreciate any help.
Craig
Last edited: