















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document, authored by dr. John cavazos from the university of delaware's computer and information sciences department, covers various topics including unix commands, if statements, arrays (or matrices), loops, scripts, and functions. The document also includes information about midterm review sessions and exams. Students are encouraged to study labs, write code for labs, and attend review sessions. Examples and explanations of unix commands, if statements, arrays, and loops, as well as an introduction to functions.
Typology: Study notes
1 / 23
This page cannot be seen from the preview
Don't miss anything!
















Dr. John Cavazos Computer and Information Sciences 03/16/
Unix commands if statements arrays (or matrices) loops scripts functions
Write code from memory Study labs ◦ Write code for labs Study Midterm review Attend review session
When you log into a UNIX terminal ◦ You are in your home directory. ◦ To see the files in your directory. ls ◦ To make an new folder/directory. mkdir exampledir ◦ To change directories. cd exampledir ◦ To go back one directory. cd .. ◦ To go back to your home directory. cd
◦ A < B A is less than B ◦ A > B A is greater than B ◦ A <= B A is less than or equal to B ◦ A >= B A is greater than or equal to B ◦ A == B A is equal to B ◦ A ~= B A not equal B
if (N <= 5) fprintf 'blue\n'; end if (N > 5 & N <= 10) fprintf 'red\n'; end if (N > 10) fprintf 'green\n'; end
All variables in matlab are arrays An array of one element is called a scalar A one dimension array is called a vector x=3.14; scalar a = [1,2,3,4,5]; vector
Creates a 3x2 array, 3 rows, 2 columns. semicolon creates a new row.
Used when you know how many times code is to be executed. Syntax for
total = 0; for i = 1:1:1000 loop starts at 1 total = total+widget (i); loop increments by 1 end loop ends at 1000 avg = total / 1000;
The mail man/woman executes a loop. If they know the number of deliveries For loop for delivery = start : next_delivery : end deliver_mail(delivery) end
sumIt=0; for current=1:finish if (mod(current,2)==1) sumIt=sumIt+current; end end
Special type of m-file ◦ Function name same as file name Contains a function name, arguments, output, and “implementation” All variables in function are local ◦ They are not visible outside call!