% LIGHTWEIGHT_ENUMERATION by Shadow in 2024
% new command to improve readability of indexed for loops in code
enumerate = @(my_array) cell2mat(arrayfun(@(x,idx) struct("cargo",x,"idx",idx), my_array(:).', 1:numel(my_array(:).'),UniformOutput=false));
% SAMPLE CODE
clc
random_stuff = rand(1, 3)
column_list = (33:37).'
for outer = enumerate(column_list)
disp("Item Number " + string(outer.idx) +" contains the numer " + string(outer.cargo) + ".")
for inner = enumerate(random_stuff)
disp(" " + string(outer.idx) + ": random nr. " + string(inner.idx) + " is: " + string(inner.cargo) + ".")
end
end
引用
Shadow (2024). Lightweight Enumeration (https://www.mathworks.com/matlabcentral/fileexchange/168011-lightweight-enumeration), MATLAB Central File Exchange. に取得済み.
MATLAB リリースの互換性
作成:
R2024a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linuxタグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!バージョン | 公開済み | リリース ノート | |
---|---|---|---|
1.0.0 |