I am trying to plot a graph in matlab using c++. But the matlab is only giving me an empty graph.
void portfolio::viewGraph()
{
double value[20]; //store portfolio value
double time[20]; //store time
int i=0,j=1;
double cash,p;
ifstream in_file("transactionhistory.txt", ios::in);
string c;
while(in_file>>cash>>p>>c>>c>>c>>c>>c)
{
value[i]=(p+cash);
cout<<p<<endl;
time[i]=j;
cout<<time[i]<<endl;
i++;
j++;
}
Engine *ep;
if (!(ep = engOpen(NULL)))
{
return ;
}
int t=20;
mxArray *A; // assume a gets initialized, all values
A=mxCreateDoubleMatrix(1,i, mxREAL);
memcpy((void *)mxGetPr(A), (void *)value, sizeof(double)*i);
engPutVariable(ep, "value", A);
mxArray *B;
// assume a gets initialized, all values
B=mxCreateDoubleMatrix(1,i, mxREAL);
memcpy((void *)mxGetPr(B), (void *)time, sizeof(double)*i);
engPutVariable(ep, "time", B);
engEvalString(ep, "plot(date,value);" );
engEvalString(ep,"xlabel('Time')");
engEvalString(ep,"ylabel('Portfolio Value')");
}