Anda di halaman 1dari 172

University of California at Berkeley CEE 225: Dynamics of Structures

Department of Civil and Env. Engineering Fall 2003

CEE 225: Dynamics of Structures


Syllabus
Lectures: TuTh 9:30-11am (390 Hearst Mining Bldg.)

Class web site: www.ce.berkeley.edu/boza/courses/cee225

Faculty: Prof. Bozidar Stojadinovic


GSI: Mr. Wei He

Course Description: This course is about computing the response of structures under dynamic
loading, such as response to an earthquake. We will examine the fundamental aspects of
dynamic equilibrium: in this sense, this course is similar to a course in statics (structural
analysis). To compute the engineering demand dynamic loads impose on a structure, we will
use analytical (closed form) and numerical methods, and focus on time-history and spectral
techniques, the main tools in engineering practice. In this course, we will also learn how
to make and use simple single- and multi-degree-of-freedom models for dynamic modelling.
Finally, structural dynamics is the basis for seismic load provisions in US building codes: we
will identify this basis and examine it in detail.
During this course, you will learn by actively participating in lectures, by solving individual
homework assignments, and by preparing for and doing exams.

Course Objectives: After you complete this course, you will be able to:

Explain the dynamic equilibrium of a structural system under dynamic loading;


Identify Single-Degree-of-Freedom and Multi-Degree-of-Freedom
Compute the responses of such systems to harmonic, pulse and earthquake loads;
Use the spectral analysis and numerical methods to compute the response of structures
to dynamic loading;
Recognize the basis for building code provisions related to dynamic loading.

Prerequisites: Undergraduate course on static structural analysis. Students who have taken CEE
125 at UC Berkeley can not take this course for credit.

Textbooks: Dynamics of Structures, Anil K. Chopra, Second Edition, Prentice Hall, 2001.

Further Reading: Dynamics of Structures, R. W. Clough and J. Penzien, Second Edition, McGraw-
Hill, 1993.
Meetings: Two 80-minute lectures per week on Tuesday and Thursday 9:3011:00am in 3111
Etchevery Hall. Please see the attached lecture plan.
Material related to each lecture will be posted on the class web site in advance. You are
expected to print out and bring this material to class. In addition, you should bring a
calculator, your notes and the textbook to participate in individual and group assignments
issued during class.

Homework: Homework will be assigned every week on Thursdays, and will be due in one week, at
the beginning of the Thursday lecture. You should solve the homework problems by yourself.
Late homework will be penalized by 20% off per day. Homework solutions must be organized
and neat. Graphs and sketches should be drawn using a ruler or by a computer application.
Multiple sheets of paper must be stapled or otherwise firmly bound together.
A folder containing homework solutions will be available at the Reference Desk in the Engi-
neering Library. Ask for the CEE 225 Homework folder.

Examinations: There will be two 90-minute midterm exams, and one 180-minute comprehensive
final exam. The midterms are scheduled during the lectures on September 25 and October 30,
2003. The final exam is scheduled on December 12, 2003, 8:0011:00 am (subject to change
by UC Administration).
Taking an exam at another time is possible, but has to be arranged with the instructor at
least two weeks before that exam. All exams will be open-book, i.e. you can use your notes,
homework solutions and the textbook. Use of computers during the exam is not allowed.
The exams are designed to evaluate your own knowledge of the course material. Therefore,
you are expected to strictly adhere to the Honor Code and neither give or receive help from
your classmates during the exams.

Grading: Your final course grade will be determined using the following formula: homework 20%;
midterm exams 25% each; and final exam 30%.

Students with Disabilities: All students have equal access to educational opportunities at UC
Berkeley. Please contact the Disabled Students Program (www.dsp.berkeley.edu) and the
instructor to address any problems that may arise regarding this issue.

Faculty: Professor Bozidar Stojadinovic, 207 2100 Shattuck (Ericsson) Building,


e-mail: boza@ce.berkeley.edu, phone: 643-7035, web-page: www.ce.berkeley.edu/boza/.
Office Hours: Tuesdays and Thursdays after class, 11:0012:30. pm in the 4th floor office
hours rooms, or by appointment.
Short Bio: I am from Belgrade, Serbia, Yugoslavia. A good way to pronounce my name is
to spell it as Bozhidar Stoyadinovich. You may call me Boza (Bozha), too. I graudate
with my Dipl. Ing. (B.S.) degree in 1988 from the University of Belgrade, my M.S. in 1990
from Carnegie-Mellon University, and my Ph.D. in 1995 from UC Berkeley (Go Bears!). I
was an Assistant Professor at the University of Michigan (Go Blue!) from 1995 until the end
of 1999. I started teaching at Berkeley in January 2000.
Besides teaching, I do research. Most of my work has to do with studying the behavior of
steel and composite structures in earthquakes, usually by doing tests in the lab. I also work
with computers, on applications of virtual and augmented reality technologies in structural
engineering, and on performance-based structural design. If you would like to take part in
some of this work, please let me know.

Teaching Assistant: Mr. Wei He, 4th floor office hours rooms, e-mail: hewei@uclink.berkeley.edu.
Office Hours: TBA.
Short Bio:
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

CEE 225: Dynamics of Structures


Lecture, Homework and Exam Plan
Date Class Hmw due Topic
08/26 L1 Introduction and Equation of Motions
08/28 L2 Free Vibration
09/02 L3 Harmonic Vibration
09/04 L4 H1 Harmonic Vibration
09/09 L5 Harmonic Vibration
09/11 L6 H2 Step Response
09/16 L7 Pulse Response
09/18 L8 H3 Numerical Methods
09/23 L9 Numerical Methods
09/25 L10 Midterm 1 (Lectures 1 through 7)
09/30 L11 Linear SDF Spectra
10/02 L12 H4 Linear SDF Spectra
10/07 L13 Non-linear SDF Spectra
10/09 L14 H5 Non-linear SDF Spectra
10/14 L15 Generalized SDF Systems
10/16 L16 H6 Generalized SDF Systems
10/21 L17 MDF System Equation of Motion
10/23 L18 H7 MDF System Equation of Motion
10/28 L19 MDF Free Vibration
10/30 L20 Midterm 2 (Lectures 8 through 16)
11/04 L21 MDF Free Vibration
11/06 L22 H8 MDF Free Vibration
11/11 Holiday
11/13 L23 H9 Linear MDF System Respose
11/18 L24 Linear MDF System Respose
11/20 L25 H10 Response of MDF Systems to Earthquakes
11/25 L26 Response of MDF Systems to Earthquakes
11/27 Holiday
12/02 L27 Building Codes
12/04 L28 H11 Conclusion and Course Evaluations
12/12 8-11am Final Exam (Comprehensive)
(**) I am planning to attend the ACI Fall 2003 Convention Sept 26 to October 1, 2003, and may have
to attend meetings related to NSFs NEES project. Watch for announcements on making up the skipped
lectures.
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Lecture 1: Introduction and Equation of Motion

Objectives:
1. Identify and define a dynamic problem.

2. Explain the generic relation between force and deformation for a structural system.

3. Derive the dynamic equation of motion.

4. Describe the total and internal coordinate systems.

Study Assignments:
1. Read Chapter 1 of Chopras textbook.
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Lecture 2: Free Vibration

Objectives:
1. Define free vibration.

2. Solve the equation of motion for an undamped SDF system.

3. Define the natural frequency and natural period of vibration.

4. Determine the level of critical damping.

5. Solve the equation of motion for a damped SDF system.

6. Discuss the characteristics of free vibration response.

Study Assignments:
1. Read Chapter 2 of Chopras textbook, Sections 2.1, 2.2 and 2.3.

2. Do Examples 2.4 and 2.7.


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Lecture 3: Harmonic Vibration: Undamped SDF System

Objectives:
1. Define harmonic vibration.

2. Explain the mathematical background for a particular and a complementary solution.

3. Itemize the steps in the solution of the equation of motion.

4. Solve the equation of motion for an undamped SDF system.

5. Discuss the two parts of harmonic response: transient and steady-state.

6. Define the displacement response factor Rd .

7. Compare dynamic and static response amplitudes.

8. Describe the response of an undamped SDF system at resonance.

Study Assignments:
1. Read Chapter 3 of Chopras textbook, Section 3.1.

2. Study Derivations 3.1 and 3.2.


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Lecture 4: Harmonic Vibration: Damped SDF System

Objectives:
1. Solve the equation of motion for a damped SDF system.

2. Discuss the two parts of harmonic response: transient and steady-state.

3. Define the displacement response factor Rd and phase angle .

4. Characterize the amplitude and the phase of response using the response factors and phase
angle in terms of the frequency ratio /n .

5. Describe how to measure the natural frequency and the damping ratio of a SDF system.

Study Assignments:
1. Read Chapter 3 of Chopras textbook, Section 3.2.

2. Study Derivations 3.3.

3. Study Example 3.2.


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Lecture 4: Harmonic Vibration: Energy and Transmission

Objectives:
1. Compute the kinetic, potential and damping energy components of a vibrating SDF system.

2. Demonstrate energy is balanced at every instant of SDF system vibration.

3. Describe the difference between the dynamic and the static hysteresis.

4. Define equivalent viscous damping for a vibrating non-linear SDF system.

5. Compare the amplitude of the forcing function and the reaction of the system at the founda-
tion.

6. Define TR: transmissibility.

7. Use TR to describe the ratio of response amplitude wrt. ground motion amplitude.

Study Assignments:
1. Read Chapter 3 of Chopras textbook, Sections 3.8, 3.9, 3.5 and 3.6.
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Lecture 6: Response to Arbitrary and Step Excitation

Objectives:
1. Define a unit impulse.

2. Identify the initial conditions for free vibration after a unit impulse.

3. Use the unit response functions to compute the response to an arbitrary excitation.

4. Define a step force excitation.

5. Derive the displacement response function to step excitation and compute the maximum
displacement response.

6. Compare the maximum response to a static and a suddenly applied force of the same magni-
tude.

7. Define a step force with a finite rise time.

8. Describe the method for computing the response to such excitation by considering two re-
sponse phases: ramp and constant.

9. Discuss the properties of time-history response to such excitation.

10. Define a shock spectrum.

11. Discuss the properties of a shock spectrum for a step-with-finite-rise-time excitation.

Study Assignments:
1. Read Chapter 4 of Chopras textbook, Sections 4.1 to 4.6.
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Lecture 6: Response to Pulse Excitation

Objectives:
1. Define single-pulse excitation and discuss how it typically occurs.

2. Describe the superposition method for pulse response computation.

3. Define a rectangular pulse.

4. Compute the displacement time-history of pulse response by defining the forced and free
vibration response phases.

5. Define a shock spectrum and discuss its properties for a rectangular pulse.

6. Define a half-sine-wave pulse and discuss the shock spectrum for this excitation.

7. Define a triangular pulse and discuss the shock spectrum for this excitation.

8. Compare shock spectra for short pulses with different shapes.

9. Compute an approximate extreme responses for an arbitrary short pulse.

10. Discuss the effect of damping on short pulse response.

Study Assignments:
1. Read Chapter 4 of Chopras textbook, Sections 4.6 to 4.12.

2. Do Example 4.1.
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Lecture 8: Numerical Evaluation of Dynamic Response: Explicit


Methods

Objectives:
1. Describe why numerical methods are needed.

2. Explain the time-step integration procedure and the transition from one equilibrium state to
the next one.

3. Explain interpolation of excitation as the basis for one family of numerical methods.

4. Implement the interpolation of excitation method.

5. Discuss the properties of this numerical method.

6. Explain finite difference expressions for derivatives as the basis for one family of numerical
methods.

7. Implement the central difference method.

8. Discuss the properties of this numerical method.

Study Assignments:
1. Read Chapter 5 of Chopras textbook, Sections 5.1 through 5.3.

2. Do Example 5.1 and 5.2.


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 1: Equations of Motion and Free Vibration


Due: 09/04/2003
100 points

Question 1 (20): Chopra 1.5

Question 2 (20): Chopra 1.9 and 1.11

Question 3 (20): Chopra 1.15 and 1.16

Question 4 (20): Chopra 2.2

Question 5 (20): Chopra 2.4


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 2: Free Vibration and Harmonic Excitation


Due: 09/11/03
100 points

Question 1 (10): Chopra 2.11

Question 2 (20): Chopra 2.13

Question 3 (10): Chopra 2.15

Question 4 (20): Chopra 3.3

Question 5 (20): Chopra 3.5

Question 6 (20): Chopra 3.11


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 3: Transmissibility and Pulse Excitation


Due: 09/18/03
100 points

Question 1 (20): Chopra 3.15

Question 2 (20): Chopra 3.16

Question 3 (30): Chopra 4.3

Question 4 (30): Chopra 4.8


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 4: Impulse Excitation


Due: 09/23/03 (TUESDAY!!!)
100 points

Question 1 (30): Chopra 4.12

Question 2 (30): Chopra 4.17

Question 3 (40): Chopra 4.26


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 4: Impulse Excitation


Due: 10/07/03 (Tuesday)
100 points

Question 1 (35): Chopra 5.3, 5.4 and 5.6

Question 2 (35): Chopra 5.7, 5.8 and 5.9

Question 3 (30): Chopra 5.10


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 6: Earthquake Spectra


Due: 10/14/03 (Tuesday)
100 points

Question 1 (35): Chopra 6.11

Question 2 (35): Chopra 6.14

Question 3 (30): Chopra 6.23


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 6: Earthquake Spectra


Due: 10/23/03 (Thursday)
125 points

Question 1 (25): Chopra 8.2

Question 2 (25): Chopra 8.5

Question 3 (25): Chopra 8.7

Question 4 (25): Chopra 8.10

Question 5 (25): Chopra 8.18

NOTE: this is a longer homework, therefore it is due next THURSDAY and its worth 125
points.
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 6: Earthquake Spectra


Due: 11/13/03 (Thursday)
150 points

Question 1 (25): Chopra 9.4

Question 2 (25): Chopra 10.5

Question 3 (25): Chopra 9.5

Question 4 (25): Chopra 10.6

Question 5 (25): Chopra 10.8

Question 6 (25): Chopra 10.9

NOTE: this is a long homework, therefore it is due next THURSDAY and its worth 150 points.
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 6: Earthquake Spectra


Due: 11/20/03 (Thursday)
100 points

Question 1 (25): Chopra 12.4

Question 2 (25): Chopra 12.6

Question 3 (25): Chopra 12.14

Question 4 (25): Chopra 12.18


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Homework 10: Response Spectrum Analysis


Due: 12/02/03 (Tuesday)
100 points

Question 1 (25): Chopra 13.1

Question 2 (25): Chopra 13.3

Question 3 (25): Chopra 13.40 (do not do RHA, use a spectrum from Ch. 13)

Question 4 (25): Chopra 13.47


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Practice Midterm 1
09/25/03 (9:30-11am 390 Hearst Mining)
100 points

Covered: Chapters 1 through 4. Topics: Equation of motion, response of a SDF system in free
vibration, and to harmonic, arbitrary, step and pulse excitation.

Question 1 (25): Chopra 1.12

Question 2 (25): Chopra 2.14

Question 3 (25): Chopra 3.12

Question 4 (25): Chopra 4.25 a) and c)


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Practice Midterm 2
10/30/03 (9:30-11am 390 Hearst Mining)
100 points

Covered: Chapters 6 through 8, with references to Chapters 1 to 4. Topics: Equation of motion,


response of a GSDF system in free vibration, and to harmonic, arbitrary, step, pulse and earthquake
excitation. Earthquake spectra.

Question 1 (20): Chopra 8.3

Question 2 (20): Chopra 8.9

Question 3 (20): Chopra 8.17

Question 4 (20): Chopra 8.19

Question 5 (20): Chopra 7.8


CEE 225 Midterm 1 Solutions
CEE 225 Midterm 2 Solutions
University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Practice Final
10/12/03 (8-11am TBA)
100 points

Topics: Equation of motion, mode shapes and periods, and response of a MDF system in free
vibration, and to harmonic, arbitrary, step, pulse and earthquake excitation.

Question 1 (20): Chopra 9.18

Question 2 (20): Chopra 10.28

Question 3 (20): Chopra 13.27

Question 4 (20): Chopra 12.16

Question 5 (20): Chopra 12.19

Extra Credit: A 2-DOF system is shown below. Masses 1 and 2 are the same and equal to 100/g
lb. Stiffness k1 = 100 lb/in, while stiffness k2 is unknown. A vibration test was conducted to
determine stiffness k2 : the shape of the fundamental vibration mode is shown in the figure.
Do the following:

1. Determine the second mode shape, using the form shown in the figure.
2. Determine stiffness k2 [lb/in].
3. Compute the natural periods of both vibration modes.

u1 u2

k k2
1
m1 m2

0.67 1.0

?.? 1.0
Do this exam in 180 minutes. Read the problems carefully. Do the ones easiest for you first.
Make sure you write what you know about to each problem, even if it is not the entire solution:
there is only one grade I can give you for a blank page.

Exam Rules:
1. You must do the exam by yourself, without anyones help.

2. You can bring your notes, your textbook and your homework.

3. You must bring your calculator (no portable computers!) and ENOUGH PAPER to write
your answers.

4. Write clearly, explain your reasoning, and circle your answers.

5. SIGN THE FRONT PAGE AND STAPLE TOGETHER YOUR EXAM.


University of California at Berkeley CEE 225: Dynamics of Structures
Department of Civil and Env. Engineering Fall 2003

Final: MDF Systems


12/12/03, 50 Bridge, 180 minutes

Name

Problem Points Maximum


1 20
2 20
3 20
4 20
5 20
total 100

Honor Pledge:

I have neither give nor received aid during this examination, nor have I concealed any
violation of the Honor Code.
Problem 1: (20%)
The shape of the first mode of vibration of this 2-story shear building is shown. Determine the
shape of its second mode and SKETCH it.

w1=90 kips 1 2 1 1 2

w2=180 kips
1/3

Problem 2: (20%)
Mass M , concentrated at a point without rotational inertia, is supported on a massless column of
length 2L and flexural rigidity EI. The bottom of the column is attached to a rigid bar of length
L and uniformly distributed mass totaling M . This rigid bar is supported on a hinge at its left end
on a spring of stiffness K = EI/L3 on its right end. A vertical dynamic load, p2 (t) is applied at
the right end of the bar, as shown.

(10%) Write the equation of motion for this two-DOF system in matrix form. Use the two
degrees of freedom shown in the figure. Neglect damping. Remember that the tip deflection
of a cantilever of length L and stiffness EI under a unit force at the tip is 3EI/L3 .

(10%) Compute the coordinates of the two modes-shapes of this system and the associated
modal vibration frequencies in terms of M and K.

u1

EI
2L
p (t)
2





K u2




L
Problem 3: (20%)
Do the following steps in a preliminary design of a 4-story building shown bellow (k = 100kips/in;
m = (100/g) kips sec2 /in):

(5%) Formulate the equation of motion for this building, given a ground acceleration time-
history u
g (t), assuming there is no damping.

(10%) ESTIMATE the fundamental-mode vibration period of this building. Note: a reason-
able estimate can be computed by means other than solving an eignevalue problem.

(5%) Use a design pseudo-acceleration spectrum provided bellow to make a reasonable esti-
mate of the base shear force and the relative displacement of the roof with respect to the
ground for this building.

m
k=100 kips/in
m=100/g kips-sec2/in
k k
m
A/g

k k
m 0.6

0.3/T
k k
m
0.2
k k












































































































































0.1 0.5 1.0 T(sec)
:

ug(t)
Problem 4: (20%)
A two-story frame is shown bellow. The mass of each floor is m = 2kip sec2 /in. The lateral
stiffness of each column is k = 300kips/in. There is no damping.
Determine the function that describes the free vibration of the roof of the frame, given that the
frame was released from an initially displaced position shown bellow (roof moved 0.414 inches to
the right, first floor moved 1 inch to the left).

m u1
      
0.414"
k k
m u2
1"
2k 2k
                                  
                                  
                                  
                                  

Problem 5: (20%)
The two-story frame in Problem 4 is to be designed for earthquake loading. A pseudo-acceleration
spectrum is shown bellow.

(5%) What is the peak ground acceleration prescribed by this design spectrum?

(10%) Estimate the peak roof displacement of the frame.

(5%) Estimate the peak base shear.

m u1 A/g
0.7
k k 0.28/T
m u2

0.25
2k 2k
                                  
                                  
                                  

0.1 0.4 1.0 T(sec)


CEE 225 Fall 2003 Final: Solution
CE 225, Fall 2005

Instructor: Professor Anil Chopra


chopra@ce.berkeley.edu
OH: 11:00-12:00 TT

GSI: Alidad Hashemi


alidad@ce.berkeley.edu
OH: 11:30-1:00 MW (504/508 Davis)
12:00-1:00 TT (504/508 Davis)

Announcements:
Alidads office hours next week will be as follows:

th
Monday (12 ): 11:00 - 1:00 pm
th
Tuesday (13 ): 2:00 - 4:00 pm
th
Wednesday (14 ): 11:00 - 1:00 pm

Professor Chopras OHs:


th th
Monday (12 ) and Wednesday (14 ) 2:00-3:00 pm

Homework solutions:
Chapter 1 1.7 , 1.9 , 1.15
Chapter 2 2.2, 2.14, 2.17
Chapter 3 3.5, 3.11, 3.12, 3.14
Chapter 4 4.11, 4.15, 4.17, 4.26
Chapter 5 5.1, 5.10 , Introduction to Matlab
Chapter 6 6.3, 6.11, 6.18 , El Centro ground motion
[g]
Chapter 7 7.1, 7.2, 7.5
Chapter 8 8.6, 8.19
Chapter 9 9.4, 9.7, 9.13
Chapter 10 10.5, 10.11, 10.23
Chapter 11
Chapter 12 12.9, 12.10
Chapter 13 13.5, 13.9, 13.17, 13.7, 13.41
Problem 3.11
% Introduction to Matlab
% For the first time try to run this file step by step, you can do
this by
% selecting (highlighting) the section you want to run and pressing F9
% Alidad, Fall 2005

clc ; % cleans the command window


clear ; % clears all the variables in the workspace
close all ; % closes all the open figures

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Variables:
k = 3.73 ; % kips/in % Note: Using ";" at the end of the statement
makes the result NOT be printed in the command window
Tn = 0.5 ; % sec
wn = 2*pi/Tn ; % pi is a constant variable with default value of
"3.14159...."
m = k/wn^2
wn = sqrt(m/k) ;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Vectors
v1 = [1 2 3]
v2 = [0 -1 1]
% dot product:
v3 = v1.*v2
v4 = k*v2

v4(1)
v4(2) = 0 ; v4
% Transpose:
v5 = v4'

length(v3)
% try "help length" in the command window
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matrices:
M1 = [1 2 3 ; 0 -1 1 ; 0 0 1] ;
% or:
M1 = [1 2 3 ;
0 -1 1;
0 0 1] ;
% or
M1 = [v1 ; v2 ; 0 0 1] ;

M1(1,2) = 0 ;
M1(3,1) = 1 ;
M1(:,1)
M1(1,:)
M1(2:3,2:3)

M2 = inv(M1)
% or
M2 = M1^(-1)
M3 = M1'

I = M2*M1
M3 = v1'*v2

% Eigenvalues, eigenvectors. Try "help eig" in the command window


lamda = eig(M1)
[phi,lamda] = eig(M1)

size(phi) ; % try "help size" in the command window

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Arrays: Generalization
% Arrays can be of any dimension
% good for storing results, parametric studies etc...
A(:,:,1) = M1 ;
A(:,:,2) = M2 ;
A

clear A ; % only clears array "A"


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
help /
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
whos
who
clear ; clc ;
%%%%%%%%%%%%%%%%%%%%%
% A few useful commands:
A = 2 ;
if (A==1)
disp('A is one!')
else
disp('BORING!')
end
%%%%%%%%%%%%%%%%%%
for i = 1:2:10
why
end
% don't be surprized, the matlab people wanted to have some fun, so
they
% created the "why" command ..., try " help why" in the command window
%%%%%%%%%%%%%%%%%
i = 0 ;
while i<5
why
i = i+1 ;
v(i) = 2^i ;
end
%%%%%%%%%%%%%%%%%
% Now let's get serious, you are going to need to load data files into
% vectors and matrices. For example, make sure you have the file
% 'GroundAcceleration.txt' in the same folder as your matlab file,
this file
% contains the accelerationen time history of an earthquake. The time
step
% and units for this file are 0.02 sec and g's.
clc; clear ;

a = load('GroundAcceleration.txt') ; % Try help load


N = length(a) ;
dt = 0.02 ;
t = 0:dt:(N-1)*dt ;

figure ; % opens a figure and returns the handel


plot(t,a,'b-')
xlabel('time')
ylabel('Acc [g]')
grid on

g = 386.4 ;
v = cumtrapz(t,a*g) ;
d = cumtrapz(t,v) ;

figure ; % opens a figure and returns the handel


subplot (3,1,1)
plot(t,a,'b-')
ylabel('Acc [g]')

subplot (3,1,2)
plot(t,v,'b-')
ylabel('Velocity [in/sec]')

subplot (3,1,3)
plot(t,d,'b-')
ylabel('Displacement [in]')
xlabel('time [sec]')

% try help plot and get yourself familiar with the options available

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Of course you can do much much more with matlab, it has many
powerful
% tool boxes (such as symbolic, simulink, time series, control, etc.)
The
% main purpose of this lecture was to make you comfortable with the
basics
% and make you learn how to teach yourself.
% To get started try help for the following commands:
% load, fprintf, fscanf, sprintf, fopen, fclose, ...
% figure, plot, semilogx, semilogy, loglog, axis, legend, text, line,
get, set, ...
% num2str, str2num, int2str, ones, zeros, max, min, ...
% for, if, while, switch, try, ...
% you can also use many of the dos commands in matlab (sometimes with
% slightly different format) such as: dir, cd, mkdir, copy ...

Anda mungkin juga menyukai