Perform action for Cell Array without using for loop
显示 更早的评论
I have a cell array of size (100,2000) and I want to take the last row of every cell and add it to a new cell array. I'm doing this to reduce the memory requirement of the cell array. Right now I am using a for loop to loop through the cells in the array, but this being matlab there probably is a better and faster way of doing this. Anyone have an idea how to perform this calculation without using a for loop?
The code below shows what I am talking about. r is 200, c is 2000 and the if statement checks if the cell is empty or not. If it is empty I don't want to do anything, if it contains data I want the last row of the cell to be saved to a new cell array.
Is there a faster way of doing this?
for ma = 1:r
for alti = 1:c
if isempty(itteration_record{ma,alti}) == 0
input_Config.itteration_record{ma,alti} = itteration_record{ma,alti}(end,:);
end
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!