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
Scilab
(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!
== Syntax == Scilab syntax is largely based on the MATLAB language. The simplest way to execute Scilab code is to type it in at the [[command-line interface|prompt]], <code>--> </code>, in the graphical command window. In this way, Scilab can be used as an interactive mathematical [[command line interpreter|shell]]. [[Hello World!]] in Scilab: <syntaxhighlight lang="scilab"> disp('Hello World'); </syntaxhighlight> Plotting a 3D surface function: <syntaxhighlight lang="scilab"> // A simple plot of z = f(x,y) t=[0:0.3:2*%pi]'; z=sin(t)*cos(t'); plot3d(t,t',z) </syntaxhighlight> Determining the equivalent single index corresponding to a given set of subscript values:<ref>{{github|https://github.com/pygments/pygments/blob/master/tests/examplefiles/scilab/scilab.sci|pygments/tests/examplefiles/scilab/scilab.sci}}</ref> <syntaxhighlight lang="scilab"> function I=sub2ind(dims,varargin) //I = sub2ind(dims,i1,i2,..) returns the linear index equivalent to the //row, column, ... subscripts in the arrays i1,i2,.. for an matrix of //size dims. //I = sub2ind(dims,Mi) returns the linear index //equivalent to the n subscripts in the columns of the matrix Mi for a matrix //of size dims. d=[1;cumprod(matrix(dims(1:$-1),-1,1))] for i=1:size(varargin) if varargin(i)==[] then I=[],return,end end if size(varargin)==1 then //subindices are the columns of the argument I=(varargin(1)-1)*d+1 else //subindices are given as separated arguments I=1 for i=1:size(varargin) I=I+(varargin(i)-1)*d(i) end end endfunction </syntaxhighlight>
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)