Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
MATLAB
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Graphics and graphical user interface programming == <graph>{ "version": 2, "width": 400, "height": 200, "data": [ { "name": "table", "values": [ { "x": 3, "y": 1 }, { "x": 1, "y": 3 }, { "x": 2, "y": 2 }, { "x": 3, "y": 4 } ] } ], "scales": [ { "name": "x", "type": "ordinal", "range": "width", "zero": false, "domain": { "data": "table", "field": "x" } }, { "name": "y", "type": "linear", "range": "height", "nice": true, "domain": { "data": "table", "field": "y" } } ], "axes": [ { "type": "x", "scale": "x" }, { "type": "y", "scale": "y" } ], "marks": [ { "type": "rect", "from": { "data": "table" }, "properties": { "enter": { "x": { "scale": "x", "field": "x" }, "y": { "scale": "y", "field": "y" }, "y2": { "scale": "y", "value": 0 }, "fill": { "value": "steelblue" }, "width": { "scale": "x", "band": "true", "offset": -1 } } } } ] }</graph> MATLAB has tightly integrated graph-plotting features. For example, the function ''plot'' can be used to produce a graph from two vectors ''x'' and ''y''. The code: <syntaxhighlight lang="matlab"> x = 0:pi/100:2*pi; y = sin(x); plot(x,y) </syntaxhighlight> produces the following figure of the [[sine wave|sine function]]: [[File:Matlab plot sin.svg|350px]] MATLAB supports three-dimensional graphics as well: {| |- | valign="top" |<syntaxhighlight lang="matlab">[X,Y] = meshgrid(-10:0.25:10,-10:0.25:10); f = sinc(sqrt((X/pi).^2+(Y/pi).^2)); mesh(X,Y,f); axis([-10 10 -10 10 -0.3 1]) xlabel('{\bfx}') ylabel('{\bfy}') zlabel('{\bfsinc} ({\bfR})') hidden off </syntaxhighlight> | | valign="top" |<syntaxhighlight lang="matlab"> [X,Y] = meshgrid(-10:0.25:10,-10:0.25:10); f = sinc(sqrt((X/pi).^2+(Y/pi).^2)); surf(X,Y,f); axis([-10 10 -10 10 -0.3 1]) xlabel('{\bfx}') ylabel('{\bfy}') zlabel('{\bfsinc} ({\bfR})') </syntaxhighlight> |- | This code produces a '''[[wire frame model|wireframe]]''' 3D plot of the two-dimensional unnormalized [[sinc function]]: | | This code produces a '''surface''' 3D plot of the two-dimensional unnormalized [[sinc function]]: |- | style="text-align:center;"|[[File:MATLAB mesh sinc3D.svg]] | | style="text-align:center;"|[[File:MATLAB surf sinc3D.svg]] |} MATLAB supports developing [[graphical user interface]] (GUI) applications.<ref>{{cite web| url=http://www.mathworks.com/discovery/matlab-gui.html | title=MATLAB GUI | publisher=MathWorks | date=April 30, 2011 | access-date=August 14, 2013}}</ref> UIs can be generated either programmatically or using visual design environments such as ''GUIDE'' and ''App Designer''.<ref>{{cite web|title=Create a Simple GUIDE GUI|url=http://www.mathworks.com/help/matlab/creating_guis/about-the-simple-guide-gui-example.html|publisher=MathWorks|access-date=August 14, 2014}}</ref><ref>{{cite web|title=MATLAB App Designer|url=https://www.mathworks.com/products/matlab/app-designer.html|publisher=MathWorks|access-date=November 1, 2019}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)