Append matrix?

6 次查看(过去 30 天)
Trader
Trader 2012-3-31
I'm currently building a cell matrix that is roughly 13x500 by adding a new row each time through a loop:
for i = period_start:1:period_end
... calculate values going into matrix ...
full_data(counter,:) = {counter current_date current_time position pa bp num_shares entry_price price sma t_band goshort l_band golong profit};
counter = counter + 1; end
I am using the counter because period_start does not always start at 1. Is there a way to append my values to the matrix without having to deal with the counter? I would like to build the array by passing the information to a function but I see my code getting very messy by passing counters. If I could send the values to the function and let it append it to the matrix I think I'd be in good shape. I would appreciate any recommendations you could provide.
Thank you

回答(1 个)

Jan
Jan 2012-3-31
The counter is the best idea, most of all because it allows to pre-allocate the result.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by