Hello moh mor
To address the errors and to modify your MATLAB code for compatibility with GPU Coder for code generation, you need to ensure that all operations are supported for GPU execution and that the data types and allocations are GPU compatible. Here are some adjustments and considerations:
- Preallocate Arrays: Arrays need to have memory pre-allocated to them and can undergo manipulation and not change of size. For example, in the following code snippet, ‘expT’ has been initialised as an empty array but is being assigned a matrix of size [15 x 16 x 2916].
expT = cat(2,expT,expT2(:,:,:,i));
Determine the size of array and pre-allocate the memory.
- Use GPU-Compatible Functions: Verify that all functions used are compatible with GPU Coder. The “save” function is not supported by GPU Coder.
- Change the function definition: Since the function is not returning any value, you can change the definition as follows.
function BPmimo2C(Efield)
Kindly modify your code by following the above guidelines and run the conversion to resolve the issue.
I hope you find the above explanation and suggestions useful!