lesson 1 Flashcards
(19 cards)
What does load do
load your previously saved variables from saved files into the current workspace
What does clear do
clear all variables in the workspace
clc
clear all code in the command window
save
save your variables in the workspace into a file
what are the rules when creating a variable
- need to start with a letter
- can only have letters, numbers and underscores
- capitals matter
- cant have more then 63 characters
what does the ; and , do
when writing matrices what does ; do
when assigning variables placing a ; at the end of the line does not let the variable eco back in the command within the window
; or , can allow you to assign two variables in one line of code e.g
x = 42, y = 87; (this will both not eco back and assign 2 variable in one line of code)
although if you use , like in example 42 will eco back
; signifies the end of a row
what does … do
allows you to continue with you line of code but on the next line down
e.g
r = u…
y
and it would give uy
errors
syntax is an error in the form e.g 1=x (need to have a variable on the left hand side)
semantics is an error in the meaning (the code wont catch this one immediately like a syntax error)
how can you find out what a command does easily within the command window
you can type help and then the name of the command, this will pop up with the command and all adjacent commands and what they do
what does the function length give you?
(Graphs)
it gives you the number of elements in a function (when dealing with plotted graphs)
when plotting a graph what does ‘*’ do
it replaces the standard line graph with a * to represent each point plotted like a scatter graph (lines are not connected like a line graph)
what does ‘ ‘ do?
for example when plotting graphs you can use this for…
this tells MATLAB not to treat those characters as the name of an operation, variable or function. instead it treats the characters between the quotes as just a string of characters called a - string
changing the things about the graph e.g coulor of line, shape of plot points ect
e.g
»plot(x_cordinate, y_cordinate, ‘rsquare’) is red square points
or shortened as:
» plot(x_cordinate, y_cordinate, ‘rs’)
how to label a graph…
xlabel(‘example’}
ylabel(‘example’)
title(‘example’)
how to manually set what axis are displayed
how to get rid of axis
> > axis([0, 12, -10,20])
need to explain what brackets are used and that the first coordinates set the the range for the x axis and the second set the range for the y axis
> > axis off
how do you change the graph to bar chart?
bar(X,Y)
how to get another figure
> > figure
how to close (a) figure(s)
> > close 1
or
close 2
ect
or
close all
how to stop MATLAB
ctrl c
how should you go about viewing a saved image within a file on a figure
save the image to a variable
e.g
»pretty_picture = imread(‘palace.JPG’)
the picture is captured in the variable pretty picture
the use the functioan image to veiw whats in teh veriabel
»image(pretty_picture)
imread(‘palace.JPG’) loads the image into matlab but you should always assign it to a variable otherwise the command window will be clogged with all the code for the image