How to count number of times code has been run (is this even possible)?

6 ビュー (過去 30 日間)
Daelyn Greene
Daelyn Greene 2019 年 1 月 15 日
コメント済み: Daelyn Greene 2019 年 1 月 15 日
I am working on code for a school project that writes data to Excel. I want the row that the data is put in to be based on the number of times the code has been run (ex: if code has been run once put data into second row, second run in third row, third run in fourth row, etc.). I feel like there's probably a simple fix to this that I'm just not seeing. Any advice would be greatly appreciated.

採用された回答

Walter Roberson
Walter Roberson 2019 年 1 月 15 日
function write_data_to_excel(data)
persistent counter
if isempty(counter); counter = 0; end
counter = counter + 1;
location = sprintf('A%d', counter);
sheet = 1;
xlswrite('FileNameGoesHere.xls', data, sheet, location )
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by