0% found this document useful (0 votes)
30 views

Time in The Course

The document provides an estimate of the time required to complete various parts of a course. It estimates that the introductory material will take 30 hours, assignments 30 hours each, and labs 90 hours total across 3 credits. The total estimated time is 180 hours. It then breaks down the scheduled activities across two periods as 18+0=18 hours for intro material, 14+12=26 hours for lectures and lessons, and 34 hours for labs, for a total of 78 hours of scheduled time and 102 hours of estimated homework.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Time in The Course

The document provides an estimate of the time required to complete various parts of a course. It estimates that the introductory material will take 30 hours, assignments 30 hours each, and labs 90 hours total across 3 credits. The total estimated time is 180 hours. It then breaks down the scheduled activities across two periods as 18+0=18 hours for intro material, 14+12=26 hours for lectures and lessons, and 34 hours for labs, for a total of 78 hours of scheduled time and 102 hours of estimated homework.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Time in the course

Each hp is 30-35h of work. We estimate 30h for simplicity.


N.B! This give a lower bound on the required work:

STONE intro 1hp ~ 30h


Assignment 1hp ~ 30h
Laborations 3hp ~ 90h
Exam 1hp ~ 30h

Sum: ~ 180h

Approximately the scheduled activity looks as follow


(period 1 + period 2):

STONE: 18h + 0h = 18h


Lectures: 8h + 6h = 14h
Lessons: 6h + 6h = 12h
Laborations: 14h + 20h = 34h

Sum: = 78h
Home work: = 102h

You have 6 laborations with a number of assignments in


each. If you spread the home time evenly it is about 17h on
each laboration, but the later laborations will require more
time.
We have an estimate on how much time each part will
require. It should give you a hint of how to plan your time.
but be aware you may need more time. The estimated time
will not by far sum up to the total time.
Variables and constants

Automatically created when you put a value in them.

X = 7
Y = ’A’
Z = ’Kalle’

Defined by:

• a namn (X)
• a datatype (integer)
• a value (7)

Stored in the computer memory!


X: 7

If you put a new value in a old variable it will automatically


be converted to hold the new datatype.

Thus you can change datatype:

X = 7
X = ’Kalle’

Variables can be deleted:

clear
clear X
Assignment

General form of assignment statement:

Variable = Expression

Examples of some assignments in a program.

count = 7
count = 3.14 % Suitable name?
pi = 3.14
x = pi / 2
y = sin(x)
positive = abs(x * -y)

i = 3 / 2;
i = ceil(3 / 2);
i = floor(3.0 / 2.0);
i = mod(3, 2);
i = i + 1;
i = ’2’;
i = ’0’ + ’1’; % Result?
b = true;
b = (I < 8);

The difference between the first group of assignments and


the second is that the second set of assignments will not
show the assigned value on screen.

You can (read SHALL) always put a semicolon last to


prevent the statement to print to screen. If we intend to
write to screen we use a special statement for that.
Operators

Arithmetic operators:

+ - * / ^ .+ .- .* ./ .^

Logic operators:

and & or | not ~ xor

Relational operators (also logic operators):

== ~= < > <= >=

N.B! The priority of operators can be modified by using


parentheses just as in math.

N.B! When you use several relational operators in an


expression you should (read shall) use parentheses to easier
see the actual order of evaluation.
Comments

Matlab provide two ways to insert comments in your


program code. A comment is regular text supposed to be
ignored by the computer, but helpful for the programmer.

1) A single line

% Comment

2) A comment the span several lines

%{
Comment using several lines.

A new line must follow immediately


after the first %{, but it is not
required after the finishing tag.
%}

One reason to the above could be to enable the following


single line comment:

switch a
case 2 %{2,3,4}
end
In- and output (I/O) - 1 of 3

To let the user enter input data to your program you need a
way to “read” the keyboard. The following instruction
achieves that:

x = input(’Enter a number: ’);

The text inside the parentheses will be written on the screen


to guide the user. Then the user is expected to enter a value
before the program continue. The value will be stored in
the variable ”x”.
The message is display every time, it is not affected by the
semicolon. (This is one circumstance we intend to display a
message on the screen.)
In- and output - 2 of 3

In matlab you can do input and output in several ways.


Only ”input”, ”disp”, and ”fprintf” describe our intention
to do input or output from a program.

x
x =
10

disp(x);
10

disp([’x = ’, num2str(x)]);
X = 10

fprintf(’x = %03d\n’, x);


x = 010

The displayed output is shown in blue above. This is just to


be able to see what was input and what was output from
Matlab.

You can observe the we use no semicolon after the first x


(unintended output), but we use one in the other examples
(intended output).

We will in general use ”disp” when we want output. But it


is good to have access to ”fprintf” when printing tables in a
nice format.
The ”unintended” version is mostly used to temporarily
test things or trace the program execution.
In- and output - 3 of 3

You can select various ”format” of the output.

format compact
format loose

format long
format long e
format short
format short e

clc

Try them out on the lab too see exactly how they work.
Figures - 1 of 1

Good commands to know to draw figures:


plot(x, y);

figure; % figure(1);
clf;

hold on;
hold off;

You can make ’plot’ behave different by adding extra


configuration parameters.
plot(x, y, ’r’);
plot(x, y, ’b+’);
plot(x, y, ’md’, ’MarkerSize’, 2)
plot(10, 10, ’r+’, ...
20, 20, ’bd’, ...
20, 20, ’m*’)

Some plot options you can use:


b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
w white v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
Sequence

A number of statements/instructions are executed after


each other.

Statement_1;
Statement_2;
Statement_3;
...
Statement_N;

N.B! You usually use semicolon, ”;”, to avoid displaying


the result of all statements (normally only the final result is
interesting). You do not have to, but as said earlier...

You might also like