Hello,
I am trying to implement a for loop which fills (and re-sizes) a temp matrix (temp_data) based on a column value criteria from another matrix (data). The data matrix comes from a text file which has the format:
a b c d e f g h 1
i s o e k n s i 1
w j r v d f a q 1
i n s e v y h a 1
o x d g q e s p 2
p q a i d f x w 2
o d s c n q e d 2
basically, there is a bunch of stock price data, always 8 columns long, with an identifier in the 9th column.
I want to create a temporary matrix in the first loop which contains only the rows with "1" in column 9, then in the next loop with "2" and so on... During each loop I will run a series of functions and output results, appending a results matrix after each loop.
This is a snippet of the code that I added to my source file:
double temp_data = NULL; //temporary matrix
int u = 654; // u = the total number of periods in the time series
for (int i=1; i<=u; i++)
{
if(data[n][k] == 'i')
{
temp_data = data[n][k];
}
******a bunch of other code here*******
}
Please don't laugh at me - I really don't know C++ and I am finding this difficult. Basically, the temp_data is not filling with values. It may be that the data[n][k] array is the problem. I could take directly from the .txt data file but I thought I would try to pull from an already populated matrix earlier in the code.
I am aware that I haven't even addressed how to realloc memory for a matrix but I guess that will have to come later :-0
I can post more of my code if necessary.
Thank you so much for any insights.
bk