Skip to content

Instantly share code, notes, and snippets.

@louisfisch
Last active February 18, 2016 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louisfisch/6ac561cb49069ab5c5c2 to your computer and use it in GitHub Desktop.
Save louisfisch/6ac561cb49069ab5c5c2 to your computer and use it in GitHub Desktop.
Some Scilab functions I find useful

Content

  • new_graphic_window() - Checks other existing graphic windows. If so it creates a new graphic window without erasing previous ones.
  • fact(k) - Takes an integer as argument. Returns k!.
  • sumfunction(StartIndex, EndIndex, Fct)- StartIndex and EndIndex are signed integers and Fct is a function (defined with deff() for instance). Let k be an integer then the function sumfunction returns the sum of Fct(k) for k = StartIndex, ..., EndIndex.

Usage

  1. Download the useful-functions.sci file and move it into your project's directory.
  2. Copy and paste the line exec useful-functions.sci at the beginning of your file (after clear; if you use it).
  3. Call any function you need.
function new_graphic_window()
AllCurrentFiguresId = get('figures_id');
if isempty(AllCurrentFiguresId) then
NewFigureId = 0;
else
CurrentFigure = get('current_figure');
CurrentFigureId = CurrentFigure.figure_id;
NewFigureId = CurrentFigureId+1;
end
scf(NewFigureId);
clf(NewFigureId);
endfunction
function f = fact(k)
if k==1 then
f=1
else
f=k*fact(k-1);
end
endfunction
function S = sumfunction(StartIndex, EndIndex, Fct)
S = sum(feval((StartIndex:EndIndex),Fct));
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment