how to write data in different columns in same sheet ?

2 views (last 30 days)
Dear all, I need to write a program in which the output of every day in a month has to be displayed in different coloumns of a same sheet(30 or 31 or 27(february) according to the months).Output of a day is just a number.So please kindly suggest steps to do this.

Answers (1)

ag
ag on 29 Dec 2024
Hi Ajay,
To write a program that outputs daily data for a month into different columns of the same sheet, you can use MATLAB and its built-in functions for handling dates and Excel files. Below is a self explanatory code on how to do this:
% Define the year and month
year = 2023;
month = 2; % For February, change as needed
% Calculate the number of days in the month
numDays = eomday(year, month);
% Initialize a matrix to store outputs
outputData = zeros(1, numDays);
% Generate output for each day
for day = 1:numDays
% Replace this with actual logic
outputData(day) = day;
end
filename = 'MonthlyData.xlsx';
% Write the data to the Excel file
writematrix(outputData,filename)
For more details, please refer to the following MathWorks documentations:
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!