Model()
Mathematical Programming
Model() is a MATLAB®-compatible mathematical programming function for create an optimization model for lp, mip, or qp. methods: m.addvar(name, lb, ub) — continuous variable m.addvar(name, 'binary') — binary (0/1) variable m.addvar(name, lb, ub, 'integer') — integer variable m.addvars(n, name, ...) — 1d array of variables m.addvars([r,c], name, ...) — 2d array of variables m.setobjective(expr) — set linear/quadratic objective m.addconstr(expr, 'name') — add constraint (<=, >=, ==) result = m.solve() — solve and return result linear models route through the same fuse-first browser solver stack as linprog/intlinprog. result fields: status, objval, vars, duals, exitflag, solvetime. Run it online in your browser with SimLab — free, no install, no license required.
Create an optimization model for LP, MIP, or QP. Methods: m.addVar(name, lb, ub) — continuous variable m.addVar(name, 'binary') — binary (0/1) variable m.addVar(name, lb, ub, 'integer') — integer variable m.addVars(n, name, ...) — 1D array of variables m.addVars([r,c], name, ...) — 2D array of variables m.setObjective(expr) — set linear/quadratic objective m.addConstr(expr, 'name') — add constraint (<=, >=, ==) result = m.solve() — solve and return result Linear models route through the same FUSE-first browser solver stack as linprog/intlinprog. Result fields: status, objVal, vars, duals, exitflag, solveTime
Syntax
m = Model('minimize')m = Model('maximize')Examples — run Model() in your browser
% LP: Product mix
m = Model('maximize')
x = m.addVar('tables', 0, Inf)
y = m.addVar('chairs', 0, Inf)
m.setObjective(70*x + 50*y)
m.addConstr(4*x + 3*y <= 240, 'wood')
result = m.solve()▶ Run% MIP: Knapsack with addVars
m = Model('maximize')
items = m.addVars(3, 'x', 'binary')
val = [10, 8, 3]
m.setObjective(val * items)
m.addConstr([5, 4, 1] * items <= 10)
result = m.solve()▶ RunSee Also
More Mathematical Programming Functions
Browse other free, MATLAB®-compatible mathematical programming functions in SimLab:
Frequently Asked Questions about Model()
Is the Model() function free to use in SimLab?
The browser workspace requires no MATLAB® license or installation. Connected features require network access and may have account, tier, availability, or usage limits. You can open Model() and 510+ other MATLAB®-compatible function references at simulations4all.com/simlab.
Do I need to install MATLAB to use Model()?
No. SimLab’s core parser, workspace state, and most functions run locally in your browser. The Model() function requires no MATLAB® license or desktop software download.
What does Model() do?
Create an optimization model for LP, MIP, or QP. Methods: m.addVar(name, lb, ub) — continuous variable m.addVar(name, 'binary') — binary (0/1) variable m.addVar(name, lb, ub, 'integer') — integer variable m.addVars(n, name, ...) — 1D array of variables m.addVars([r,c], name, ...) — 2D array of variables m.setObjective(expr) — set linear/quadratic objective m.addConstr(expr, 'name') — add constraint (<=, >=, ==) result = m.solve() — solve and return result Linear models route through the same FUSE-first browser solver stack as linprog/intlinprog. Result fields: status, objVal, vars, duals, exitflag, solveTime. It is a MATLAB®-compatible mathematical programming function available in SimLab with the same calling syntax as MATLAB® — typically: m = Model('minimize').
Can I run Model() in my browser?
Yes. Open SimLab at simulations4all.com/simlab, write or paste code that calls Model(), and run it. This function’s calculation runs locally in the browser. SimLab session analytics, sharing, feedback, and eligible acceleration have separate network boundaries.
Try SimLab — MATLAB®-compatible, free, in your browser
510+ functions. Runs in your browser. No install. No license.
Open SimLabMATLAB® is a registered trademark of The MathWorks, Inc. SimLab is an independent project by Simulations4All and is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.