Notes from January 23 Wednesday
Matlabs name came from Matrix Laboratory, it is very efficient in
dealing with arrays and matrices.
Matlab has a number of file maintenance commands so you would not
need to leave the software to process files. It has a sel
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2008
CE108/Johnson
Final Exam
Spring 2006 Name: _
Instructions: 1) Write your name/initials in the place(s) provided. 2) Please write neatly and legibly. Problem 1 (20 points) Program Execution a. What are the values of the variables after the followin
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2014
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http:/w
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2010
% Matthew Vine
% 1/26/11
% This is a program that reads the given parameters.
proj2a
m=input('Enter the mass:');
theta=input('Enter theta in degrees:');
td=input('Enter theta dot in rad/sec:');
tdd=input('Enter theta dot dot in rad/sec^2:');
t=theta*pi/18
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2010
% Matthew Vine
% 1/19/11
% The Surface Area of a Rectangular Prism
L=input('Enter the length:');
W=input('Enter the width:');
H=input('Enter the height:');
term1=W*H;
term2=L*W;
term3=L*H;
area_surf=2*(term1+term2+term3);
fprintf('The Surface Area of a Re
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2010
CE 108 Notes (1/18/11)
Fprintfcould be written on a file or a script
Example: fprintf( The area is 0\n, Area);
If there is more than one value:
Example:
a(1,:)=theta;
b (2,:)=Fs;
A(3,:)=N;
fprintf(The result is 0, 0, 0\n, a b A);
0\n equals a floating n
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2010
2/15/11
CE 108 Notes
Finding roots of a function
Rootpoint where equation crosses the xaxis(x=0)
Finding regions where we are guaranteed to have a root.
Matlab function rootlook
Find a good approximation of each root
Matlab function bisection
divides
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2010
2/8/11
CE 108 Notes
0Floating number; precise to the decimal
0Integer ( 1, 2, 3, etc.);
To determine the number of rows and columns:
[r,c]=size(data) (*If data is the name of the matrix)
fprintf(The number of rows and columns are 0 and 0, respectively.\
Tentative Notes from March 21 Wednesday To work on Project 8, you need to download a file from the class website that is specifically designed for you. You could reach it using the link: http:/wwwclasses.usc.edu/engr/ce/108/project8/ After you find your
Notes from March 7 Wednesday Today's discussion centers on the Gaussian Elimination algorithm. Many years after its introduction, it is still the fastest algorithm for solving matrix equations if the matrix is full. There are many other algorithms for spe
Notes from January 23 Monday While the matlab command "a=15.4" generates a single memory location assigned to the variable name a. The matlab command "a=eye(3)" generates a 3 by 3 identity matrix for a and there are 9 elements. Similarly, "a=zeros(5)" gen
Notes from January 18 Wednesday Matlab's name came from Matrix Laboratory, it is very efficient in dealing with arrays and matrices. Matlab has a number of file maintenance commands so you would not need to leave the software to process files. It has a se
Notes from January 11 Wednesday The most important things to know about writing an algebraic expressions are the rules of precedence. They define clearly how matlab would interpret your expression. The first step of the interpretation is call "parsing," w
Notes from January 09 Monday Instructor: Professor H.L. Wong, 35th year at USC. H.L. is an Hawaiian name, Hang Loose. Preferred to be called "doc" as that is my basketball playground name. CEE Students have used that name for the past 26 years or so. The
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2010
% Matthew Vine
% 2/2/11
% Project 3
% This program uses a recurrence relationship to calculate Bessel's
series.
x=input('what is the value of x?');
J0=1;
S=1;
J1=(1/2)*x;
T=(1/2)*x;
for i=1:9
S=(1/2*x)^2/(i^2)*S;
T=(1/2*x)^2/(i*(i+1)*T;
J0=J0+S;
J1=J1+T
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2010
%Matthew Vine
% 2/9/11
% Matlab program that outputs the following results.
0ata=csvread('12345.csv');
data=[1.2 3 4 5 7; 0 2 9 27 8; 0.6 0.2 0.1 0 2];
[r,c]= size(data);
N=r*c;
fprintf('The number of rows and columns are 0 and 0, respectively.\n',
r, c
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2010
%Matthew Vine
% 2/16/11
%Project 5
function root=bisection(aa, bb)
a=aa;
b=bb;
f1=f(a);
for i=1:10
c=(a+b)/2;
fc=f(c);
z=f1*fc;
if (z>0)
a=c;
f1=fc;
else
b=c;
end
end
root=(a+b)/2;
function [a,b]=rootlook(x1,x2,dx)
xx1=x1;
f1=f(xx1);
i=0;
while (xx1<x2)
x
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2014
#Type the colour and not the word
#from usingpython.com
#import the modules we need, for creating a GUI.
import tkinter
#.and for creating random numbers.
import random
#the list of possible colour.
colours =
['Red','Blue','Green','Pink','Black','Yellow',
Introduction to Computer Methods in Civil Engineering
CE 108

Spring 2014
import pygame
#  Globals # Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
# Set the width and height of each snake segment
segment_width = 15
segment_height = 15
# Margin between each segment
segment_margin = 3
# Set initial speed
x_change = segment_w
Notes from January 14 Monday
Instructor: Professor H.L. Wong, 37th year at USC. H.L. is a Hawaiian
name, Hang Loose. Preferred to be called doc as that is my
basketball playground name. CEE Students have used that name for
the past 29 years or so.
The ce1
Notes from January 30 Wednesday
The ce108 students agreed that for an infinite series, all the terms
must be related somehow because it is impossible to create an infinite
number of things without some relationship between them. In fact,
the socalled ran
Notes from January 28 Monday
While the matlab command a=15.4 generates a single memory
location assigned to the variable name a. The matlab command
a=eye(3) generates a 3 by 3 identity matrix for a and there are 9
elements. Similarly, a=zeros(5) generates
Notes from February 4 Monday
Project 3 requires you to program the summation of two mathematical
series. The first step is to obtain the recurrence relations of the two
series. The program can be done without the recurrence by simply
using factorials, but
Notes from February 20 Wednesday
Most of the lecture was spent on deriving the Extended Trapezoidal
Rule and the Extended Simpsons Rule. The concept of sampling
theory and the basis of the NewtonCotes formulation were also
explained.
A Matlab function fo
Notes from February 6 Wednesday
The major difference between a calculator and computer was
explained. The user of a calculator is required to make decisions to
aid the calculation process whereas a computer program has decision
making capabilities to allo
Notes from February 25 Monday
From a users point of view for an integration program, it is not good
to prompt for the number of sample points because most users are not
certain how many sample points are required to accurately represent
an integral. It is
Notes from February 13 Wednesday
To implement the Bisection Method, the script fp.m is not needed, only
f.m will be accessed. The main script bis.m can be written as:
clear all
global n;
global a;
n=input('Enter n:');
a=input('Enter a:');
A=0.;
B=a;
FA=f(
Notes from February 11 Monday
Instead of using a for loop for nr.m, a while loop could also be used:
clear all
global n;
global a;
n=input('Enter n:');
a=input('Enter a:');
xn=1;
error=1;
while error >1e14
xnp1=xnf(xn)/fp(xn);
error=abs(xnp1xn);
xn=xnp
Notes from January 11 Wednesday
The most important things to know about writing an algebraic
expressions are the rules of precedence. They define clearly how
matlab would interpret your expression. The first step of the
interpretation is call parsing, whe