Matlab Programming You can think of a spreadsheet as a matri
Matlab Programming
You can think of a spreadsheet as a matrix of numbers, though spreadsheet software also allows you to enter strings. CSV stands for comma separated values, and is a very portable type of spreadsheet. We will use the \"csvread\" function, perform some math on the data, and write it back with the \"csvwrite\" function. From the MATLAB help, use commands like \"M = csvread(\'FILENAME\')\" and \"csvwrite(FILENAME,M)\". Of course, you can and should use your own variable names.
Read the CSV data from the file \"somedata.csv\" into a variable the link is http://carmaux.cs.gsu.edu/~mweeks/csc4630/somedata.csv. Find the average for each row as an integer, and store that as a new column. Then write the data, including the new column, to a file called \"somedata2.csv\". Use \"type\" to display the contents of the new file.
Thanks
Solution
The given matlab code opens the csv file containing data and then compute average of the data and then store the average value in the new column of the csv file and save the file
Data =dlmread(\'inputFile.csv\'); % this command is used to read the data from the given file
meanValue =mean(Data(:)); % this command is used to compute the mean of the data present in file
dlmwrite(\'inputFile.csv\' ,meanValue.\'-append\'d); % this is used to store the computed mean value in the file
% append is used to store the computed data in the same file
% dlmread() function requires the delimeter to be specified but here since comma(,) is default delimeter and csv file have comma delimited data hence there is no need of specifying delimeter value
