How to loop through cell array and apply script to each double?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I have a cell array of cell arrays of doubles called "C_512_numeric". I have the script called edit and I want to loop through all columns in the doubles in C_512_numeric and use the column data as input for edit (first argument). I have attached the script.
How would I write this code?
0 件のコメント
回答 (1 件)
Aquatris
2024 年 7 月 26 日
編集済み: Aquatris
2024 年 7 月 26 日
a = {1:3, 200:205, 10:12};
new_a = cellfun(@(x) myfun(x) ,a,'UniformOutput',false);
new_a{:}
function y = myfun(x)
y = x*(-2);
end
2 件のコメント
Aquatris
2024 年 7 月 29 日
The script is within the answer already. What exactly is the part you are struggling with?
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!