| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB Compiler |
| Contents | Index |
| Learn more about MATLAB Compiler |
The examples in this chapter demonstrate a Magic Square Calculator application that allows users to input a size for a magic square. It shows the matrix, as well as a surface plot of the matrix. This surface plot doesn't represent anything, but it demonstrates how to handle numerical data as well as visualization data.
The applications built in this chapter are not complex multi-tiered applications. Rather, these applications represent the product of the least number of steps required to build a working Web application quickly. The concepts demonstrated in this chapter can be extended into a robust, scalable Web application using techniques from other chapters in this guide.
The getMagicWebFigure.m MATLAB function,
which runs the Magic Square calculator, is as follows. It is based
on the popular Magic Square getMagic function:
getmagic.m:
function magicOutput = getMagic(x)
magicOutput = magic(x);
end
getMagicWebFigure.m:
function figureOutput = getMagicWebFigure(x)
f = figure;
magicOutput = magic(x);
surf(magicOutput);
set(gcf,'Color',[1,1,1])
figureOutput = webfigure(f);
close(f);
end
The Magic Square Calculator application, when built, looks like this.
Magic Square Calculator Application Presented on the Web

![]() | Role of the End-To-End Developer | Creating an End-to-End Web Application | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |