transforming c++ array to matlab big matrix using file -


in code i'm changing array (int*) , want compare matlab results.

since array big 1200 x 1000 element. takes forever load matlab

i'm trying copy printed output file matlab command line...

for (int = 0; < _roiy1; i++) {     (int j = 0; j < newwidth; j++)     {         channel_gr[i*newwidth + j] = cliplevel;     } }  ofstream myfile; myfile.open("c:\\users\\gdarmon\\desktop\\opencvcliptop.txt"); (int = 0; <  newheight ; i++) {     (int j = 0; j < newwidth; j++)     {         myfile << channel_gr[i * newwidth + j] << ", ";     }     myfile<<";" <<endl; } 

is there faster way create readable matrix data c++? matlab?

the simplest answer it's quicker transfer data in binary form, rather - suggested in question - rendering text , having matlab parse binary. can achieve using fwrite() @ c/c++ end, , fread() @ matlab end.

int* my_data = ...; int my_data_count = ...;  file* fid = fopen('my_data_file', 'wb'); fwrite((void*)my_data, sizeof(int), my_data_count, fid); fclose(fid); 

in matlab:

fid = fopen('my_data_file', 'r'); my_data = fread(fid, inf, '*int32'); fclose(fid); 

it's maybe worth noting can call c/c++ functions within matlab, depending on doing may easier architecture (look "mex files").


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -