EXERCISES WEEK 1
Exercise 1.8
%% Task 1
>> t=(0:0.1:10)
%% Task 2
>> y1=sin(2*t)
>> y2=2*cos(3*t)
>> y3=tan(t)
%% Task 3
>> plot(t,y1,’-k’)
>> hold on
>> plot(t,y2,’--r')
>> plot(t,y3,’-.m’)
>> hold off
>> ylim([-5 5])
%% Task 4
>> legend(‘y1’,’y2’,’y3’)
>> xlabel('Time (s)')
%% Task 5
>> subplot(3,1,1)
>> plot(t,y1,’-k’)
>> xlim([1 9])
>> xlabel('Time (s)')
>> subplot(3,1,2)
>> plot (t, y2,‘--r')
>> xlim([1 9])
>> xlabel('Time (s)')
>> subplot(3,1,3)
>> plot(t,y3,’-.m’)
>> xlim([1 9])
>> xlabel('Time (s)')
, Exercise 1.9
>> load StudentsNL.mat
%% Task 1
% Having the data points connected by a line is not practical because there’s no order of time. The
individual data points represent independent observation from numerous participants. Connecting the
dots would suggest a continuous relationship that doesn’t exist. Not to mention that it would be quite
difficult to interpret, given the fact that there would be lines everywhere.
>> plot(weightNL,lengthNL,'ok')
%% Task 2
>> xlabel('Weight (kg)')
>> ylabel('Length (cm)')
>> title('Weight vs Length')
%%Task 3
>> Mean_Length=mean(lengthNL)
>> plot(weightNL,Mean_Length,'-k')
>> hold on
>> Mean_Weight=mean(weightNL)
>> plot(Mean_Weight,lengthNL,'-k')
>> xline(mean(weightNL))
>> yline(mean(lengthNL))
Exercise 1.8
%% Task 1
>> t=(0:0.1:10)
%% Task 2
>> y1=sin(2*t)
>> y2=2*cos(3*t)
>> y3=tan(t)
%% Task 3
>> plot(t,y1,’-k’)
>> hold on
>> plot(t,y2,’--r')
>> plot(t,y3,’-.m’)
>> hold off
>> ylim([-5 5])
%% Task 4
>> legend(‘y1’,’y2’,’y3’)
>> xlabel('Time (s)')
%% Task 5
>> subplot(3,1,1)
>> plot(t,y1,’-k’)
>> xlim([1 9])
>> xlabel('Time (s)')
>> subplot(3,1,2)
>> plot (t, y2,‘--r')
>> xlim([1 9])
>> xlabel('Time (s)')
>> subplot(3,1,3)
>> plot(t,y3,’-.m’)
>> xlim([1 9])
>> xlabel('Time (s)')
, Exercise 1.9
>> load StudentsNL.mat
%% Task 1
% Having the data points connected by a line is not practical because there’s no order of time. The
individual data points represent independent observation from numerous participants. Connecting the
dots would suggest a continuous relationship that doesn’t exist. Not to mention that it would be quite
difficult to interpret, given the fact that there would be lines everywhere.
>> plot(weightNL,lengthNL,'ok')
%% Task 2
>> xlabel('Weight (kg)')
>> ylabel('Length (cm)')
>> title('Weight vs Length')
%%Task 3
>> Mean_Length=mean(lengthNL)
>> plot(weightNL,Mean_Length,'-k')
>> hold on
>> Mean_Weight=mean(weightNL)
>> plot(Mean_Weight,lengthNL,'-k')
>> xline(mean(weightNL))
>> yline(mean(lengthNL))