In the following, we've written a code to create a .csv file to store our data. This is a template code that I am using for one of my project.
Note: The loop allows for appending different modified versions of the data matrix to the file in each iteration. Its a template again. Must be modified as per need.
% Clear the command window and workspace
clc;
clear all;
% Example numeric matrix
data = [1, 2, 3; 4, 5, 6; 7, 8, 9];
% Column names
colNames = {'Thruput', 'Base', 'Col'};
% Specify the desired file name
filename = 'data.csv';
% Iterate three times
for iter = 1:3
% Check if the file exists
if isfile(filename) == 0
% File does not exist, write column names and data
writecell(colNames, 'data.csv');
writematrix(data, filename, 'WriteMode', 'append');
else
% File exists, append modified data
writematrix(data * (iter + 1), filename, 'WriteMode', 'append');
end
end