how can I save the output data of each run in new row ?
    10 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Walaa
 am 2 Mär. 2023
  
    
    
    
    
    Beantwortet: Sivapriya Srinivasan
    
 am 2 Mär. 2023
            how can I save the  output data of each run in new row ? I used append but it just overwrites the old values
0 Kommentare
Akzeptierte Antwort
  DUY Nguyen
      
 am 2 Mär. 2023
        Hi,
You can initialize an empty matrix with the desired number of rows and columns, and then use indexing to add each set of output data as a new row.
Here's an example:
% Initialize empty matrix to store output data
output_data = [];
% Loop through each run
for i = 1:num_runs
    % Run some code to generate output
    output = my_function(input_data);
    % Append output data to matrix as a new row
    output_data = [output_data; output];
end
% Save output data to a file
save('output_data.mat', 'output_data');
0 Kommentare
Weitere Antworten (1)
  Sivapriya Srinivasan
    
 am 2 Mär. 2023
        To save the output data of each run in a new row when append overwrites the old values 
This can be done depending on the input data available. 
- The number of runs are known:
     MATLAB’s dynamic array functionality to create an empty matrix and append output from each run as a new row using an iterator thus it avoids the overwriting problem.  
- The number of runs are unknown:
     Then we can use a while loop instead of a for loop to keep iterating until a condition is met and may use a break statement to come out of the loop. 
Hope this helps! 
0 Kommentare
Siehe auch
Kategorien
				Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


