simple mortgage calculator web app
this example shows how to create a web app and host it on the development version of matlab® web app server . the example uses the simple calculator app from app designer as a basis for the web app. for information about the app and the numerical values you can enter, see . in the workflow, you:
package the simple calculator app from app designer using the web app compiler app or
compiler.build.webapparchive
in matlab compiler™. this step creates a web app archive (.ctf
) file.deploy the web app archive (
.ctf
) file to the development version of matlab web app server.run the web app from the web apps home page.
prerequisites
install and configure the development version of matlab web app server™.
for information on installing the server, see install the development version of matlab web app server in matlab compiler.
for information on configuring the server, see .
download the matlab app file
mortgage.mlapp
to your current working directory by executing:setupexample("matlab/mortgagecalculatorexample",pwd)
package and create web app using web app compiler
start matlab.
type
webappcompiler
at the matlab command line to open the web app compiler app.in the main file section of the toolstrip, click the button to add the
mortgage.mlapp
file to the project. the web app compiler automatically resizes to include an app details section that contains information about the app such as app name, author, summary, description, and version. you can edit information about the app in app designer by clicking edit app details. click refresh to update web app compiler with any changes you have made.(optional) make sure to use a display name that is easy to distinguish when your web app is deployed to the server.
(optional) provide a version number for tracking purposes. the version number is visible on the web apps home page.
(optional) add a description for your web app in the summary field. this description is visible on the web apps home page.
in the archive information section, specify the archive name as
mymortgagewebapp
.click package to package the app, and create a web app archive (
.ctf
file).in the save project dialog box that opens, specify a project name and a location where you want to save the web app project. web app compiler saves your project and opens a package dialog box.
once packaging is complete, in the package dialog box, click open output folder. this opens the project folder, which contains the following files:
mymortgagewebapp.ctf
mccexcludedfiles.log
packaginglog.html
requiredmcrproducts.txt
you can view the log file,
packaginglog.html
, to see the exactmcc
syntax used to package and create the web app archive.
package and create web app using compiler.build.webapparchive
note
if you have already created a standalone application using the web app compiler app, you can skip this section. however, if you want to know how to create a web app from the matlab command window using a programmatic approach, follow these instructions.
build a web app archive using the
compiler.build.webapparchive
command. use name-value arguments to specify the archive name.buildresults = compiler.build.webapparchive('mortgage.mlapp',... 'archivename','mymortgagewebapp');
the
compiler.build.results
objectbuildresults
contains information on the build type, generated files, and build options.the build function generates the following files within a folder named
mymortgagewebappwebapparchive
in your current working directory:mccexcludedfiles.log
— log file that contains a list of any toolbox functions that were not included in the web app. for more information on non-supported functions, see .mymortgagewebapp.ctf
— component technology file that contains the deployable archive.requiredmcrproducts.txt
— text file that contains product ids of products required by matlab runtime to run the web app.unresolvedsymbols.txt
— text file that contains information on unresolved symbols.
deploy web app
navigate to the project folder generated by matlab compiler during the packaging process.
copy the web app archive file
mymortgagewebapp.ctf
to the app folder configured by the server. the default location is:operating system apps folder location windows®
%programdata%\mathworks\webapps\r2023a\apps
linux®
/local/mathworks/webapps/r2023a/apps
macos
/library/application support/mathworks/webapps/r2023a/apps
you can also open the apps folder by clicking the open app folder button in the server application. for more information, see .
click the open home page button in the server application.
this action opens the web apps home page using your default web browser. you see a tile displaying the simple mortgage calculator web app. your web app is now deployed.
run web app
to run a web app, click the
mymortgagewebapp
tile on the web apps home page.the web app opens in a new tab.
click the monthly payment button to get the monthly payment and the principal and interest graph.
you have successfully created, deployed, and run a web app.
mortgage calculator web app