% http://users.fs.cvut.cz/ivo.bukovsky/CSS/2013/

clear all   % clears the workspace
close all   % close all plots

% F5 .. saves the m-file and runs the script

% plot function y=sin(omega*t)
% t=0,0.1,0.2,...,60

omega=0.1;

% generate time vector

t=0:0.1:60;  % ... row vector, 1x601
size(t)  % dimension of the array (vector, matrix)

% more common is to have variables in column vectors
% vector transposition
disp(' transposition of t')
t=t';
size(t)

% % first 10 elements of t
% 
% t(1:10)  % Matlab is indexing in round brackets from 1
% 
% % last element of t
% t(end)
% % second last
% t(end-1)
% % last 10 elements of t
% t(end-9:end)
% % Resampling
% teverysecond=t(1:2:end)

y=sin(omega*t)

% ploting the results

% plot(y)
plot(t,y), grid on, xlabel('time [sec]')
ylabel('y,z [/]'), title('functions y=sin(omega*t), z=y^2')

%another function z(t)=y(t)^2
%z=y^2 ... this is like y*y ... vector multiplication 
% we need the square of each element of y
z=y.^2 % = y.*y ... squares each element

% plot this in the same axes in green
hold on  % do not delete previous drawing
plot(t,z,'g')




