- eomday - https://www.mathworks.com/help/matlab/ref/eomday.html
- writematrix- https://www.mathworks.com/help/matlab/ref/writematrix.html#:~:text=writematrix(M%2C%27M.xls%27)
how to write data in different columns in same sheet ?
조회 수: 13 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
ag
2024년 12월 29일
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!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!