Discovering Computer Science: Matlab Basics, Schemes and Mind Maps of Computer science

Click on the “Getting Started” link in Matlab. ... While not a MATLAB command, this keystroke ... log10( x ) - common logarithm, base 10.

Typology: Schemes and Mind Maps

2022/2023

Uploaded on 03/01/2023

maya090
maya090 🇺🇸

4.3

(23)

285 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
10/30/2019
1
Discovering Computer Science:
Matlab Basics
John T. Bell
Department of Computer Science
University of Illinois, Chicago
4
Typical Matlab Environment
pf3
pf4
pf5

Partial preview of the text

Download Discovering Computer Science: Matlab Basics and more Schemes and Mind Maps Computer science in PDF only on Docsity!

Discovering Computer Science:

Matlab Basics

John T. Bell

Department of Computer Science

University of Illinois, Chicago

4

Typical Matlab Environment

5

How to get help in Matlab

  • Click on the “Getting Started” link in Matlab.
  • Type “lookfor keyword” to find a list of all

commands dealing with “keyword”.

  • To get help on a particular command , try:
    • help command
    • helpwin command
    • doc command 6

Common Matlab Commands

Command Description clc Clears the command window. Does not affect the workspace, meaning variables are unchanged. clear Clears all variables from the workspace, so all variable values are lost. exit Exits the MATLAB session. who Prints all variables in the current workspace. whos Prints all variables in the current workspace as well as some extra information about their size, bytes, class, etc. ctrl-c While not a MATLAB command, this keystroke sequence interrupts an endless MATLAB calculation that a programmer may have entered accidentally. Afterwards, the programmer can enter a new command. Table 1.2.1: Regularly used MATLAB commands.

9

Basic Matlab Math Operators

Convention Description Explanation ( ) Items within parentheses are evaluated first ^ Power is evaluated next. Thus 52^3 evaluates as 5(2^3) or 58 which is 40. *** /* Next to be evaluated are * and / having equal precedence. + - Finally come + and equal precedence.^ -^ with^ Thus, 3+2A is evaluated as 3+(2A). left-to-right If more than one operator of equal precedence could be evaluated, evaluation occurs left to right. Thus, A2/3;" evaluates as (A2)/ Table 2.5.2: Precedence rules for arithmetic operators. 10

Matlab Library Math Functions

  • sin, cos, tan, sec, csc, cot, asin, acos, atan, asec, acsc, acot, and degree version, e.g. sind.
  • exp( x ) - ex, exponential
  • log( x ) - natural logarithm, base e
  • log10( x ) - common logarithm, base 10
  • sqrt( x ) - square root
  • Find commands with ‘lookfor keyword’
  • help/helpwin/doc ‘name’. ( Try elfun, specfun )
  • See also “Mathematics” under “Getting Started”.

11

Review

Which of the following constants is NOT pre-

defined in Matlab?

A. e - The base for natural logarithms

B. i, j - The square root of - 1

C. Inf - infinity, e.g. 1 / 0

D. NaN - Not a Number, e.g. 0 / 0

E. pi

12

Review

Which of the following expressions is equivalent to: x + 5 * y / z ^ 2 A. ( x + ( ( 5 * y ) / z ) ) ^ 2 B. ( ( x + 5 ) * ( y / z ) ) ^ 2 C. x + ( 5 * y / z ) ^ 2 D. x + ( ( 5 * y ) / ( z ^ 2 ) ) E. ( x + ( 5 * y ) ) / ( z ^ 2 )