- The Galois Group
- Activities
- The Graduate Program
- Funding
- Other Advice
- Student-run Seminars
- Technical Tutorials
- About Davis
- External Links
by Sarah Williams
updated 9/15/2003
Please note that MatLAB can be accessed both on the department computers and from home via SSH. From home, one can even combine SSH with X Windows to use the graphical version of MatLAB.
MATLAB is both a programming language and a software package. "MATLAB"
stands for "Matrix Laboratory." Accordingly, many features exploit
matrices, and assume you are working with matrices. MATLAB
generally solves
problems numerically, not symbolically (compared to Mathematica).
>> B = [7 8 9]';
(note the apostrophe)
>> C = A*B;
>> C
>> C'
>> A(1,2)
>> A(2,1)
>> B
>> B(1,1)
>> B(1)
>> B(3)
>> X = 1:5
>> Y = 3:0.3:5
>> Z = [0:(pi/4):(2*pi)]'
>> clear
>> c = -pi/2;
>> X = [0:0.1:1]';
>> sin(c)
Now, type the "up" arrow.
MATLAB will display the last thing you typed.
(Type "up" again and you can move backwards through your command
history.) Use the arrow keys
to edit the last line to read:
>> sin(X)
>> sqrt(c)
(Note the imaginary value.)
>> sqrt(abs(c))
>> Y = exp(X)
>> Z = log(Y)
>> clear
>> X = -2:0.1:2;
>> Y = sqrt(4-(X.^2));
>> plot(X,Y)
Now is the time when we talk about Linux. If you already
know which directory you will save your program files in, skip to the
next section.
% My Name
plot(X,Y)
function Y = circle2(radius)
X = -radius:0.1:radius;
Y = sqrt(radius^2-(X.^2));
plot(X,Y)
>>circle2(1);
% with radius = 1,2,3, and 4.
for j = 1:4
circle2(j);
end
>> clear
>> makecircles
% My Name X = -radius:0.1:radius;
% The Date
% The purpose of this program is to plot a semi-circle of a
% given radius.
function Y = circle2(radius)
Y = sqrt(radius^2-(X.^2));
figure
plot(X,Y)
function Y = circle2(radius)
X = -radius:0.1:radius;
Y = sqrt(radius^2-(X.^2));
%figure
hold on
plot(X,Y)