You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
Find all combinations of entries in a matrix (or vector) which sum equals a certain number. In addition to the matrix, the length of the combination (two entries, three entries, ...) as well as the numerical value to match can be supplied. Works as well on vectors.
Returns the combination and the indices of the combinations.
Since it uses brute force to try all possible combinations the time strongly depends on the size of the matrix and the length of the combination.
Cite As
Bastian Tietjen (2026). Solve Magic Square (https://uk.mathworks.com/matlabcentral/fileexchange/41063-solve-magic-square), MATLAB Central File Exchange. Retrieved .
Acknowledgements
Inspired by: ISEQUALFP: Check equality within floating point precision
General Information
- Version 1.1.0.0 (3.78 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
