MATLAB TEST 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Plot type: experimental data, mathematical phenomena, relationship among different data sets.

scatter plot

a file that contains a set of commands that perform a particular function. Saved with a ".m"

script

you CANNOT run a ___________ ________ if a variable has not been previously defined in the command window.

self-defined function

if time= [1.9 2.9 3.8 4.6 5.5 6.3 7.1] distance= 10:10:100 and: average_speed= distance/time what is the result? a ____ value [WE DONT WANT THIS] what do we have to use to correct this: use the ____ _____ which gives us speed at each time point

single/dot operator

in E= linspace(1,10,4) 1 is the _____ point 10 is the ____ value 4 is the ______ __ _____

starting/final/number of values

in the vector F= 0:2:10 0 is the _____ point 2 is the __________ 10 is the ____ _____

starting/increment/final value

the result of fprintf is written as a _________

string

write a command that loads the string name heya.txt variable name: student

student= 'heya.txt' load(student)

write a command that imports: heya.txt and assign it to the variable student

student= load('heya.txt')

Plot commands: Use this command to plot multiple data sets in the same figure but on separate axis

subplot(row, column, plot location/#)

time= [1.9 2.9 3.8 4.6 5.5 ] type up a command that will give me the third time value

time(3)

Format plot: give the plot title: Heya is amazing xlablel: classes ylabel: heya's brain cells turn on grid

title('Heya is amazing') xlabel('classes') ylabel('Heya's brain cells') grid on

flip data from row to column

transpose

true or false: variables used in one execution of one script will be carried over into the next script.

true

a one-dimensional array; composed of a single row or column of entries ex. [1,2,3,4,5,6]

vector

what does the command find sin(pi/2) do: prints a ______

vector

5 ways to get help on Matlab

website f(x) button help help command doc command

a command that gives you information about the variables defined in the work place. This command gives you the name of the variable, its size, bytes, class, and attributes

whos

above the command history: where the variables x and y are contained

workspace

scripts can access variables created in the _________

workspace

draw a log(x) graph using a colon domain of 1-10 use a star marker

x= 1:10; y= log(x) plot(x,y,'*')

create a column vector of 1-5 without commas or spaces define the vector as x

x= 1:5

Create a column vector of 1-5 without commas or colons define the vector as x

x= [1 2 3 4 5]

create a column vector of 1-5 without colons or empty spaces define the vector as x

x= [1,2,3,4,5]

find x^3 using matlab

x^3

the most basic array; contains only one entry ex. 5

scalar

fprintf the ______ tells MATLAB to insert the value of the variable after the comma as a fixed-point value with two decimal places.

%.2f

"___" tells Matlab to insert the value of the variable after the commas as a whole number

%d

fprintf %s _____ \n ______ %d ____ %f _____

%s = replacing a variable in a string with a variable name \n = enters a string one line down %d= insert number as a whole number %f= specify decimal places of a number to be printed

three different file types:

.csv .txt .dat

csvread is ____ indexed.

0

matlab starts counting at __ instead of ___. That's why the csvread command is 1,0 as row 1 column 0 when in reality it is row 2 and column 1.

0/1

fprintf the %.2f tells MATLAB to insert the value of the variable after the comma as a fixed-point value with ____ decimal places. EXAMPLE: >> temperature= 100.98405830432 temperature = 100.9841 >> fprintf('Hello it"s me, i"ve been waiting outside in this %.2f degree weather',temperature) Hello it"s me, i"ve been waiting outside in this 100.98 degree weather>>

2

In the matrix below, the rows are separated by: ____ A= [2 4; 6 8; 10 12]

;

negation of 1

>> -1

division of 15/3

>>15/3

multiplication of 3 x 3

>>3*3

add 3 +3

>>3+3

subtract 3-3

>>3-3

exponentiation of 3 to 2 power

>>3^2

Create Matrix "A" with values 2,4 in the first row 6,8 in the second row and 10,12 in the third row

A= [2 4; 6 8; 10 12]

write the command that transposes this column vector to a row vector B= [1 2 3 4 5]

B= [1 2 3 4 5]'

Use a command to make a vector that goes from 1-10 but only uses 4 values. Call this vector "E."

E= linspace(1,10,4)

Make a column vector of values from 1-10. Take a short cut so they are separated by increments of 2. Define vector as F.

F= 0:2:10

type the output: >>fprintf('Hello there')

Hello there

type the output: fprintf('Hello there\n')

Hello there (entered down a line)

type the output: name= Robert >>fprintf('Hello there, my names"s %s\n', name)

Hello there, my name's Robert (entered down a line)

What is the output: rabbits = 10 >> fprintf('Luna is a straight up %d',rabbits)

Luna is a straight up 10.

order of operations

Please Excuse Tinder Not My Dear Aunt Sally cuz P-parenthesis () E-exponentiation ^ T- transpose ' N - negation (-) M- multiplication(*) D- division(/) A- addition(+) S- subtraction (-) C- comparison (=, =< , >=, <, >)

if matrix1= [1 2; 3 4] and matrix2= [10 20; 30 40] and matrix3= matrix1.*matrix2 what does matrix 3=

[10 40; 90 160]

fprintf statement: "___" adds a line break

\n

Make three different vectors of 1-5 define them as a, b, c a -> use no spaces b -> use commas c -> use a colon

a= [1 2 3 4 5] b= [1,2,3,4,5] c= 1:5

find theta if the opposite side is 3, and the hypotneuse is 5

arcsin((3/5)*pi/180)

the fundamental form Matlab uses to store and manipulate data. It is a list of data entries arranged into rows and or columns

array

in the ______section: perform calculations and manipulate inputs

calculations

a command that will clear all data

clear

a command that will clear the variable yellow

clear yellow

format of a csv formated file

comma seperated (comma separates the fields of text)

a sequence of values, functions, or operators that performs a calculation or other function

command

the command you use to load a .csv file

csvread

the two commands used to load data:

csvread load

write a command that loads the string collegesucks.csv

csvread('collegesucks.csv')

write a command that loads a string skipping the fist row collegesucks.csv

csvread('collegesucks.csv',1,0)

format of a dat formated file

data (can include data, text, graphics)

format of a txt formatted file

delimited text (tabs separate each fields of text)

how to get a document that shows you information about the cosine function

doc cos

When working with matrices and want to use multiplication we use the ____ operator

dot

type the output: fprintf('Hello there, my name"s Robert\n') **notice how for name's in fprintf you must use "

ello there, my name's Robert (entered down a line)

write a command that loads the string name collegesucks.csv variable name= engineering

engineering= 'collegesucks.csv' load(engineering)

import data from file called: lifesucks.csv call it engineeringmajor import the x-values and call it homeworkhours which is in column 1 import the y-values and call it number of sleep hours which is in column 2 create a histogram with 8 bins format correctly with labels, etc.

engineeringmajor= csvread('lifesucks.csv') homeworkhours(:,1); sleephours(:,2) hist(sleephours,8) title('Histogram of Hours of Sleep') xlabel('hours of homework') ylabel('hours of sleep') grid on

Plot commands: used not to replace previous plot, and allows us to create a new plot

figure

windows created by plotting commands are

figures

To execute a script press ____ OR go to the command window and type the script name WITHOUT _____ and press enter.

run/.m

a command that can save a file called mydata

save mydata

given: name= 'Heya' (you need to put it in 'quotes' or it will not work) testaverage1= 65 testaverage2=54 testaverage3= 84 write a command that prints: use variable references and fprintf commands, make the score print with 3 decimal points. Hello there, my name's Heya and my test average is 67%.

fprinft('Hello there my name"s %s and my test average is %.3f.', name, (testaverage1+testaverage2+testaverage3/3))

print to screen command

fprintf

how to get help with a description printed directly on the screen for the sin function.

help sin

Plot commands: This command toggles whether existing data in a figure should be erased (done by matlab not explicitly by you)

hold

Plot commands: matlab will continue to plot on the same axis until this command is executed

hold off

Plot commands: allows us to continue to plot, plots more equations and data

hold on

in the _____ section: assign constants or variables, import data, or receive input from the user

inputs

write command: find the number of elements in the LONGEST dimension of the array: x=[1,2,3,4,5,6]

length(x)

variable name rules 1) Must start with a ________. 2)Must contain _____, ______, or _________. 3) Are ______ sensitive. 4)Must not be a Matlab __________ 5) Do not use __________ function names.

letter/letter/number/underscore/case/keyword/built-in function

Plot type: evenly spaced or sample data, time-series data taken at even intervals, displays categorical data

line plot

the command you use load a .txt file

load

the command you use to load a .dat file

load

load the variable pink in workspace

load pink

command that will load saved data, the file's name is mydata

load('mydata.mat')

write a command that will give you the ln of 10

log(10)

write a command that will give you the log of 10

log10(10)

a 2D-array; collection of entries arranged into rows and columns ex. [1,2 ; 3,4]

matrix

multiply "matrix1" and "matrix2" together using the dot operator to make "matrix4"

matrix4= matrix1.*matrix2

write command: find the maximum value of x= [1,2,3,4,5,6]

max(x)

command that finds the average of the numbers: 1,2,3,4,5

mean([1 2 3 4 5])

write command: find the minimum value of x= [1,2,3,4,5,6]

min(x)

the commands csvread and load only work on _________ data

numerical

in the ________ section: supply the final output

outputs

Plot commands: write command to plot x and y

plot(x,y)

write command: find the range of: x= [1,2,3,4,5,6]

range= max(x) -min(x)

in the _______ section: paste results and answer questions

results


Set pelajaran terkait

AP Environmental Science Chapter 1- Environment and Sustainability

View Set

Computer Science Praxis Exam Questions

View Set

Osteopathic Principles & Practice, Term 2

View Set

MRU14.1: INTRODUCTION TO PRICE DISCRIMINATION

View Set

Add, Subtract, Multiply & Divide Fractions

View Set

The invention of the light bulb.

View Set

Code Plus - deel 1 - Hoofdstuk 1 - Introductie

View Set

Chapter 14: The Brain and Cranial Nerves

View Set

Science test FILL IN THE BLANK😭

View Set

Chapter 5 Risk Analysis Assessing the risks of natural Hazards

View Set