How not to reload persistent variables twice?
2 ビュー (過去 30 日間)
古いコメントを表示
I wnat to use persistent variables to speed up, so I want to genrate data, and make it persistent at the first call, but how to check next time, that this is not the first call, and I dont want to genrate the data again?
0 件のコメント
採用された回答
Walter Roberson
2017 年 7 月 21 日
if isempty(VariableName)
... calculate initial value for variable
end
0 件のコメント
その他の回答 (1 件)
Jan
2017 年 7 月 21 日
編集済み: Jan
2017 年 7 月 21 日
function arrayToXLS(A, xlsfile, x1, x2)
persistent dblArray;
if isempty(dblArray)
disp 'Writing spreadsheet file ...'
xlswrite(xlsfile, A);
end
Undefined persistent variables are empty. If your real data might be empty also, use a persistent flag in addition:
persistent Data initialized
if isempty(initialized)
initialized = true;
Data = <what eve you want, even empty array>
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Standard File Formats についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!