Control statements & reading and writing data

Control statments

How to concatenate?

display(['Hello ' string_variable num2str(number)])

What is the syntax for a, For loop?

for num = 1:100

code

end

How many times will this code loop, and what value will num take for num = A?

It will loop for each column in A

Num will take the value of the column

What is the syntax is for a while loop?

while condition

code

end

What is the syntax for a if/elif/else statement?

if condition

code

elseif condition

code

else

code

end

What is the syntax for a switch statement?

switch var

case var1

code

case var2

code

otherwise

code

end

What does the continue keyword do?

This keyword will skip any remaining code in the loop and start the loop over again

What does the break keyword do?

This will terminate the loop

What does the return keyword do?

This terminates a function, if the function has any output they must be set before the return keyword is called

Loading and writing data

What does the save('filename') do?

This saves all variables from the workspace to a specified filename

How do you run this function in the command line?

save filename

What extension must be added to the end of the filename?

filename.mat

How to save a specific variable?

save('filename', 'var1', 'var2')

save filename var1 var2

What does the * do when following a variable name?

var* this would save all variables starting with 'var'

What does the load('filename') do?

This will load any variables from filename to the workspace

What does imwrite(image_var, 'filename', 'jpg') do?

This will save the image image_var to the file 'filename', in the jpg format

What does imread('filename') do?

This will return a image 'filename'

How would i get all .png file details from a folder named images?

dir('images/*.png')