Hi Yusra,
From the error message thrown it seems to me that the MATFile storing the network is likely corrupted. Can you try resaving the network to a new MATFile and see if loading the network using "load" in MATLAB works or not. If "load" itself fails, then codegen will also fail since during codegen the network is also loaded into MATLAB.
Also, are there any custom layers in the network that you are trying to load. It maybe that the custom layer is not on the PATH and hence loading the network fails. In that case, add the custom layer to the PATH using addPath and then try to load the network.
Hope this helps!
~Sayan