Memory predefined for Matlab tables ignoring?

I moved from collecting Matlab simulation results in structures to collecting them in tables. I am very pleased with this way of presenting the data, but I'm still not sure how to handle the preliminary allocation of memory. If I just add rows to the bottom of the table, I have a known problem of redistributing all the variables included in the table at each iteration.

I can pre-select some arbitrary number of rows and trim the table at the end of my script. But if I do this, I need to reserve the number of rows containing the actual data. This number should be taken into account during any operation on table values, and this eliminates the beauty of using this high-level object.

Is there a way to reallocate memory for a Matlab table that does not change the behavior of the table and does not require external accounting?

Edit - Explanation

My question applies not only to tables, but also to any class of Matlab variables. I have predetermined Matlab variables for many years, which upsets the lack of an efficient single-line interface that adds data without additional control. I would expect at least a table object to include some smart memory management solution. In my opinion, adding null strings to avoid redistribution does not take place in scientific code (which should be as abstract as possible).

+4
source share
1 answer

/ , , , , , , , .

, " " , , "" , , . , , :

A = zeros(2000, 1);
for i = 1:N
    A(i) = i^2;
    % i is the number of rows filled so far...
end
0

All Articles