1/12
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
state the problem clearly
describe the input and output information
work the problem (by hand or calculator) with a simple data set
develop an algorithmic solution
→ use flow chart or pseudocode
convert the solution to a computer program
test the solution with a variety data sets
what are the six steps of problem solving
something is known or given
something is to be found, estimated or decided
there is some condition to be satisfied or objective to achieve
how do we make sure we know we are solving the correct problem
syntax error → issues with syntax (i.e., the structure of our code)
semantic/logic errors → issues that may arise from misunderstanding the specific, or logical mistakes in our coding
these errors can occur at compile-time or run-time
what are the two categories of errors that we may encounter
when your code doesn’t throw an error but isn’t producing the output you’d expect
→ these can be found by testing your code after it is written
what is a silent bug
create adequate tests that consider edge cases
how do we debug a code
negative values
very large values
very small values
special values (e.g. 0,1 and -1)
identical inputs
what are examples of edge cases
allows you to set breakpoints in our code which will stop the execution of a script or function at that particular point of the program
this allows you to see the state of the script or function at that point i.e., what variables exist and what are the values stored in them
how do the built-in debugging tools in MATLAB work
using the whos function
how can we see the type of variables we have in MATLAB
MATLAB has a data type known as logical
only has two possible values: 1 or 0
we can cast a variable to a logical type by using the logical function
a zero value will become a logical 0
logical 1 represents a true state
logical 0 represents a false state
what is a logical data type
== → equal to
e.g. A == B
~= → not equal to
e.g. A ~= B
> → greater than
e.g. A > B
< → less than
e.g. A < B
>= → greater than or equal to
e.g. A >=B
<= → less than or equal to
e.g. A <= B
what relation operators are used to represent the outcomes of comparison
~ → Find logical NOT
e.g. ~A
& → Find logical AND
e.g. A & B
| → Find logical OR
e.g. A | B
how do logical operators work
logical AND with short-circuit operators → A && B && C && D && E
logical OR with short-circuit operators → A || B || C || D || E
what are examples of short circuit logical operators
if <expression>
<statements>
elseif <expression>
<statements>
else
<statements>
end
how do conditional statements work