Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Scilab
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Scilab
(section)
Add topic