1 / 10

CS 170 – Intro to Scientific and engineering Programming

CS 170 – Intro to Scientific and engineering Programming. Built-in MATLAB functions. math: sum, prod, mean, std , abs, sqrt , sin, cos, abs , exp , min, max logical: any, all, and, or, not creation: linspace , colon, ones, zeros dimensions: size, length

helen
Download Presentation

CS 170 – Intro to Scientific and engineering Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 170 – Intro to Scientific and engineering Programming

  2. Built-in MATLAB functions • math: sum, prod, mean, std, abs, sqrt, sin, cos, abs, exp, min, max • logical: any, all, and, or, not • creation: linspace, colon, ones, zeros • dimensions: size, length • graph/display: plot, figure, subplot, xlabel, ylabel, • title, axis, legend, imshow, imtool • input/output: input, disp

  3. Big idea: Abstraction

  4. The other side of the contract • We’ve been using functions built by others - let’s try writing a few of our own • Implement a myMeanfunction that returns a single value representing the average value of a vector or matrix

  5. Executing a function

  6. Invoke myMean function

  7. Arguments!

  8. Try another one? • Write a function to draw a circle • Think first about the contract: • use inputs to control appearance: radius, location, color, markers, line style, line width • Call the new function drawCircleand store it in an M-File named drawCircle.m

  9. Questions??

  10. Resources • Lecture slides CS112, Ellen Hildreth, http://cs.wellesley.edu/~cs112/

More Related