- 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 ?
1 回表示 (過去 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!