Clear Filters
Clear Filters

Append matrix?

6 views (last 30 days)
Trader
Trader on 31 Mar 2012
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

Answers (1)

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

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!