Professional Documents
Culture Documents
1.
2.
3.
4.
5.
6.
Linear equations
Free Fall
Electric Current
Cantilever Beam
Diffusion
Random Events
1. Linear Equations
Scilab
2. Free Fall
t=0, v=0,
Case 1. No air resistance
Case 2. Resistance proportional to
the linear power of velocity
Case 3. Resistance proportional to
the second power of the velocity
2. Free Fall
What is the status of the particle at
t=5?
(Given k=0.2, g=9.81m/s2)
2. Free Fall
2. Free Fall
Computation Results
Case 1
Case 2
Case 3
Case 1
Case 2
Case 3
3. Electric Current
A single, closed-loop electrical circuit
The loop contains
Solution:
3. Electric Current
V=1; R=1; L=1;
t=0:0.01:6;
i=(V/R)*(1-exp(-R.*t/L));
figure;plot(t,i,'ro');
xlabel('time,
t','fontsize',6),
ylabel('current,
i','fontsize',6)
4. Cantilever Beam
The Olive View Hospital
damaged in the 1971 San
Fernando earthquake
(original image from the
EqIIS Collection)
4. Cantilever Beam
For a uniformly loaded span of a cantilever beam attached
to a wall at x = 0 with the free end at x = L, the formula
for the vertical displacement from y = 0 under the loaded
condition, with y the coordinate in the direction opposite
that of the load, can be written as follows:
where
E is a material property known as
the modulus of elasticity;
I is a geometric property of the
cross-section of the beam known
as the moment of inertia; L is the
length; w is the load per unit width
of the beam.
4. Cantilever beam
x=0:0.01:1;
y=-(x.^4-4*x.^3+6*x.^2);
plot(x,y)
xlabel('x','fontsize',6)
ylabel('y','fontsize',6)
title('Cantilever Beam')
plot([0 1],[0 0],'linewidth',2)
legend('Uniformly loaded
beam,unloaded)
5.
Diffusion equation:
dc
2c
dt
c( x 0, t 0) 1
c( x, t 0) 0
5. Diffusion
dc
2c
dt
t
x 2
x=1:1:100; dt=0.05;
c=zeros(100,1); c(1)=1;
figure;
for t=1:1:3000
for i=2:1:99
d(i)=(c(i+1)+c(i-1)2*c(i))*dt+c(i);
end
d(100)=d(99);
d(1)=1-sum(d(2:100));
c=d;
if pmodulo(t,1000)==0
then plot(x,c);
end
end
Results
t1
c(x,t)
t2
t3
x
P=1/3 3 P=2/3
P=1/3 3 P=2/3
Transition probability
Scientific software
Two categories of general scientific
software
Computer algebra systems that perform
symbolic computations: Maple,
Mathematica, Maxima, Axiom, and
MuPad
General purpose numerical systems
performing numerical computations and
designed specifically for scientific
applications: Matlab, Scilab (free)
Scilab
A large software package containing 13,000 files, more
than 400,000 lines of source code, 70,000 lines of
Scilab code, 80,000 lines of online help, and 18,000
lines of configuration files, including
Elementary functions of scientific calculation
Linear algebra, spare matrices
Polynomials and rational functions
Classic and robust control, optimizations
Nonlinear methods (optimization, ODE solver, Scicos
dynamic systems modeler and simulator)
Signal processing
Random sampling and statistics
Graphs, graphics, animation
Programmable Calculator
Scilab
www.scilab.org
Mac
Linux
Reference
http://www.scilab.org/resources/documentati
on/tutorials
Introduction to Scilab (introscilab.pdf)
Scilab for very beginners
(Scilab_beginners.pdf)
Scilab interface
Start -> Scilab
Variable
s
Director
y
&
files
Comma
nd Input
Interfac
e
Comma
nd
history
Help
To get help, type help
> help derivative
Editor
>editor
Save as *.sce
file
To run:
exec(filename.sce)
Who is this?
Ihear, I forget
Isee, I remember
Ido, I learn
26
Variable names
Variable names may be as long as the user
wants, but only the first 24 characters are
taken into account in Scilab.
Case sensitive
a to z,
A to Z,
0 to 9,
%, _, #, !, $, ?
Starting with % has special meaning, such as
%pi
Continuation lines:
any line which ends with two dots
..
Other functions
Booleans
Boolean variables can store
true (%t, or %T) or false (%f, or %F)
values.
Complex numbers
In Scilab, %i represents the mathematical
imaginary number i
i 1?
2
is used
to compute
the
conjugate
real
returns real
part
imag
returns
imaginary
Integers
Integer type:
Number of bits used to store an
integer and the range of value:
n-bit signed integer: [-2n-1, 2n-1-1]
n-bit unsigned integer: [0, 2n-1]
Conversions between
integers
Scilab integer conversion
functions:
Strings
Strings can be stored in variables, provided that
they are delimited by double quotes .
+ can operate strings.
Home Work-1
Due: 9am, Sep 7, 2015
Late policy: 10% off per day
To be submitted online to Canvas.
Exercises (I)
Exercises (II)
Exercises (III)
What will you get by executing the following?
Exercises (IV)
What will you get by executing the
following?
Exercises (V)
What will you get by executing the
following?
Exercises (VI)
What will you get by executing the
following?
Exercises (VII)
Determine the value of the following
expressions yourself before checking
your answers using Scilab
Exercises (VIII)
Given that a=[1 0 2] and b=[0 2 2],
determine the value of the following
expressions. Check your answers
with Scilab