Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Valerie, Chino, Nick, Solomon, and David
- %AERO 321 Lab 2
- %10/10/2018
- close all ;
- clear all ;
- clc ;
- %% Question 4
- disp('Question 4')
- numDataPoints = 100;
- [t,data] = serial_reader(numDataPoints);
- Data1 = data(:,1);
- Time = t;
- d = data(:,1);
- plot(t(1:2:end),d(1:2:end),'r',t(2:2:end),d(2:2:end),'b')
- legend('damp','orig')
- %Calculating the desired quantities:
- %1) Mean
- Mean1 = mean(Data1) ;
- disp(['The mean value is', num2str(Mean1)])
- %2) Standard Deviation
- SD1 = std(Data1) ;
- disp(['The standard deviation is', num2str(SD1)])
- %3) Standard Error of the Mean
- SDError1 = std(Data1)/sqrt(length(Data1)) ;
- disp(['The standard error of the mean is', num2str(SDError1)])
- %4) Goodness of Fit
- [h, p, stats] = chi2gof(Data1) ;
- ChiSquared1 = stats.chi2stat ;
- disp(['The chi squared value is', num2str(ChiSquared1)])
- %Plotting Data vs. Time
- figure
- plot(Time, Data1)
- title('Distance vs. Time')
- xlabel('Time (s)')
- ylabel('Distance (cm)')
- %% Question 5
- disp('Question 5')
- Data2 = fopen('____.mat') ;
- %Calculating the desired quantities:
- %1) Mean
- Mean2 = mean(Data2) ;
- disp(['The mean value is', num2str(Mean2)])
- %2) Standard Deviation
- SD2 = std(Data2) ;
- disp(['The standard deviation is', num2str(SD2)])
- %3) Standard Error of the Mean
- SDError2 = std(Data2)/sqrt(length(Data2)) ;
- disp(['The standard error of the mean is', num2str(SDError2)])
- %4) Goodness of Fit
- [h, p, stats] = chi2gof(Data2) ;
- ChiSquared2 = stats.chi2stat ;
- disp(['The chi squared value is', num2str(ChiSquared2)])
- %Plotting Data vs. Time
- plot(Time, Data2)
- title('Distance vs. Time')
- xlabel('Time (s)')
- ylabel('Distance (cm)')
- %% Question 6
- disp('Question 6')
- Data3 = fopen('____.mat') ;
- %Part a
- %Calculating the desired quantities:
- %1) Mean
- Mean3 = mean(Data3) ;
- disp(['The mean value is', num2str(Mean3)])
- %2) Standard Deviation
- SD3 = std(Data3) ;
- disp(['The standard deviation is', num2str(SD3)])
- %3) Standard Error of the Mean
- SDError3 = std(Data3)/sqrt(length(Data3)) ;
- disp(['The standard error of the mean is', num2str(SDError3)])
- %4) Goodness of Fit
- [h, p, stats] = chi2gof(Data3) ;
- ChiSquared3 = stats.chi2stat ;
- disp(['The chi squared value is', num2str(ChiSquared3)])
- %Plotting Data vs. Time
- plot(Time, Data3)
- title('Distance vs. Time')
- xlabel('Time (s)')
- ylabel('Distance (cm)')
- %Part b
- %Part c
- %% Question 7
- disp('Question 7')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement