Time in The Course
Time in The Course
Sum: ~ 180h
Sum: = 78h
Home work: = 102h
X = 7
Y = ’A’
Z = ’Kalle’
Defined by:
• a namn (X)
• a datatype (integer)
• a value (7)
X = 7
X = ’Kalle’
clear
clear X
Assignment
Variable = Expression
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);
Arithmetic operators:
+ - * / ^ .+ .- .* ./ .^
Logic operators:
1) A single line
% Comment
%{
Comment using several lines.
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
x =
10
disp(x);
10
disp([’x = ’, num2str(x)]);
X = 10
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
figure; % figure(1);
clf;
hold on;
hold off;
Statement_1;
Statement_2;
Statement_3;
...
Statement_N;