CS Review Session Test 1

CS Review Session Test 1 - September 12, 2009 CS 1371...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: September 12, 2009 CS 1371 Review Session: Test 1 Matlab basics: One = sign is the assignment operator! == is when youre comparing two things (like is a equal to b?) Vectors: One dimensional array. Only one data type (cant have both chars and doubles) Creating a vector: VariableName = [data]. This is direct entry. You dont need commas Colon Operator: VariableName = [<start>:<increment>:<end/stop value>] . I t stops when its <= the end value Dont confuse this with linspace! Linspace also takes in three values. Linspace(<startingvalue>,COMMA NOT COLON <ending value>, <number of values that you want the output to be>). The results are EVENLY SPACED values between the start value and ending value. If you only give it two inputs, it will by default give you 100 output values. It may appear on the TEST with INTERPOLATION and graphing. Fun Functions: ones(1,#desired), zeros(1,#desired), rand(1,#desired) Format is rows then columns Example: ones(1,2) will return [1 1] Creating random values: If we want random values between 1 and 10 (instead of just between 0 and 1), you do this: A is starting value and B is ending value. In this case B=10 and A=1 Eq = rand(1,N)*(B-A)+A So rand(1,5)*(10-1)+1 If you need integers, use the <round> function We concatenate using square brackets[ ] Example: Vec1 = rand(1,10); Vec2 = round(rand(1:10)*10); We can use mod to get even values Vec3 = [(vec1(mod(vec1,2==0)) vec2(mod(vec2,2)==1))] This gives us the concatenated odd values of the first with the even values of the second. The outer square brackets concatenate them and the mod parts get what you want. Mod is similar to rem, but were only gonna use mod. Mod always returns positive numbers. Anytime you want to delete something, assign it using the = sign to [empty brackets] You can remove lots at a time by indexing what you want to delete with the colon operator and setting it equal to empty brackets....
View Full Document

This note was uploaded on 11/16/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.

Page1 / 11

CS Review Session Test 1 - September 12, 2009 CS 1371...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online