Why is MATLAB so fast in matrix multiplication?

I am making some benchmarks with CUDA, C++, C#, Java, and using MATLAB for verification and matrix generation. When I perform matrix multiplication with MATLAB, 2048×2048 and even bigger matrices are almost instantly multiplied. 1024×1024 2048×2048 4096×4096 ——— ——— ——— CUDA C (ms) 43.11 391.05 3407.99 C++ (ms) 6137.10 64369.29 551390.93 C# (ms) 10509.00 300684.00 … Read more

Is it possible to define more than one function per file in MATLAB, and access them from outside that file?

When I was studying for my undergraduate degree in EE, MATLAB required each function to be defined in its own file, even if it was a one-liner. I’m studying for a graduate degree now, and I have to write a project in MATLAB. Is this still a requirement for newer versions of MATLAB? If it … Read more

How can I index a MATLAB array returned by a function without first assigning it to a local variable?

For example, if I want to read the middle value from magic(5), I can do so like this: M = magic(5); value = M(3,3); to get value == 13. I’d like to be able to do something like one of these: value = magic(5)(3,3); value = (magic(5))(3,3); to dispense with the intermediate variable. However, MATLAB … Read more