02.02.2013 Views

Scilab for Real Dummies

Scilab for Real Dummies

Scilab for Real Dummies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example 1-1: 1 1: script <strong>for</strong> a<br />

simple plot<br />

�� Let’s Let s elaborate on the<br />

example from “<strong>Scilab</strong> <strong>Scilab</strong> in 15<br />

minutes” minutes<br />

�� We work with the Editor<br />

using the same script as<br />

be<strong>for</strong>e, but with added<br />

comments<br />

�� Save the function when it<br />

has been typed in. I call it<br />

plot1.sce and have saved it<br />

on my USB thumb drive,<br />

you can save it wherever<br />

you like<br />

�� To run the script, Click on<br />

the Editor’s Editor s Execute icon<br />

�� What happens is shown on<br />

the next slide<br />

// plot1.sce<br />

// A simple 2D plot of a sine function /<br />

// with the abscissa x = 0 ... 10, /<br />

// and amplitude A = increases with x /<br />

// The function itself is y(x) /<br />

x = [0:.1:10]; // The abscissa x is a row vector<br />

A = 0.5*x; // Modulated amplitude, row vector<br />

y = A.*sin(2*x); // Element-by-element multiplication<br />

plot(y) // Plot command<br />

Note: Comments begin with a double<br />

slash (//). <strong>Scilab</strong> disregards everything<br />

behind the // when it executes the code

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!