{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS Review Session Test 1

# CS Review Session Test 1 - CS 1371 Review Session Test 1...

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

September 12, 2009 CS 1371 Review Session: Test 1 Matlab basics: One = sign is the assignment operator! == is when you’re comparing two things (like is a equal to b?) Vectors: One dimensional array. Only one data type (can’t have both chars and doubles) Creating a vector: VariableName = [data]. This is direct entry. You don’t need commas Colon Operator: VariableName = [<start>:<increment>:<end/stop value>] . It stops when it’s <= the end value Don’t 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)

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

View Full Document
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 we’re 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.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern