MATLAB traditionally executes code in a single thread, which means it uses only one core of the CPU by default. However, this does not mean it is limited to 1 GB of RAM. MATLAB can use as much RAM as is available on your system, limited only by your system's architecture (32-bit vs. 64-bit) and physical memory.
To leverage multiple CPU cores and more effectively utilize your system's resources, you can use the following strategies:
- Parallel Computing Toolbox: You can use parfor loops, parfeval, and other parallel constructs to execute tasks concurrently. Here is a sample code for the same:
Please follow the below links for more information on the same:
- Vectorization: Ensure your code is vectorized as much as possible. Vectorized operations are typically faster and can utilize MATLAB's optimized libraries.
- Built-in Multithreading: Some MATLAB functions are already optimized to use multithreading internally (e.g., fft, svd, sort). Make sure to use these functions for operations that support them.
- Code Profiling: Use the MATLAB Profiler (profile on, profile viewer) to identify bottlenecks in your code and optimize those sections. Please follow this link to know more about it:
I hope this helps!