I generated code for loading a mat file as follows
data=coder.load('data.mat');
a=data.a;
b=data.b;
Because one of the variables, for example "a", is very big, it is defined as a big static const array in the main function with all values initialized there.
Is there any way I can make MATLAB Coder load data from a file in C Code instead of defining it as a variable in main function?
This is the exact code that we should use based on Ryan's answer:
load('Data.mat')
fileID = fopen('Data.bin', 'w');
fwrite(fileID, Matrix1,'uint64');
fclose(fileID);
fileID=fopen('Data.bin');
Matrix2=fread(fileID,[256,256],'uint64');
fclose(fileID);
Matrix 2 is now the same as Matrix 1. The trick for writing and reading is to use the same precision based on the data type.