Field II kidney example does not work due to "Requested array exceeds the maximum possible variable size." error

8 views (last 30 days)
I am trying to run on my computer example provided by FIELD II site: Field II Ultrasound Simulation Program (field-ii.dk). I create all the simulated rf-data as in example. When it comes to produce B-mode image function fast_int is called. It's .C program for fast interpolation. On the website was given fast_int.mexw32 file only so I converted .c file using mex function into .mexw64. And it does not work even though all my variables are set exacly as in the example.
I provide below given message and fast_int code in txt format. If anyone could direct me why this example is not executable in my case i would highly appriciate. I wonder if this example was run on different system or matlab version and somehow there was no variable size problem? I am not familiar with c programming so i am not sure where exacly in the main function problem occurs.

Accepted Answer

James Tursa
James Tursa on 20 Sep 2023
At first glance this is the obvious problem in the original source code: The dimensions array needs to be the proper integer size for API calls, so you need to change this:
int dimension[2];
to this
mwSize dimension[2];
Also, you may get a compiler warning on this conversion:
(unsigned char *) mxGetPr(etc)
so I would change it to this instead:
(unsigned char *) mxGetData(etc)

More Answers (1)

Himanshu
Himanshu on 20 Sep 2023
Hey,
I understand that you are encountering the error "Requested array exceeds the maximum possible variable size" when trying to run a MEX function.
This error typicallyoccurs when your code asks MATLAB to create an array which is larger than MATLAB can theoretically create. The requested array would have more elements than the maximum number of elements an array can possibly have in MATLAB.
Here are some ways of handling the error:
  1. Try to reduce the size of the problem.
  2. Change the type of the variable being used to ensure that the array takes less space.
  3. Divide the problem into smaller subproblems.
For a detailed description of the error and ways of handling the problem, you can refer to the following MALTAB Answer:

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!