MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: CONDITION/DATA ANALYSIS/PLOTS

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107917] Re: [mg107892] Re: CONDITION/DATA ANALYSIS/PLOTS
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 2 Mar 2010 07:56:05 -0500 (EST)
  • Reply-to: hanlonr at cox.net

xd = RandomReal[{0, 1}, 10];

yd = RandomReal[{0, 1}, 10];

zd = RandomReal[{0, .1}, 10];

use Pick to select elements of xd and yd based on corresponding element of zd

xdnew = Pick[xd, zd, _?(# < .05 &)];

ydnew = Pick[yd, zd, _?(# < .05 &)];

zdnew = Select[zd, # < .05 &];


N[Mean[xd], 6] does not round

Mean[xd] // InputForm

0.45700132031309676

N[Mean[xd], 6] // InputForm

0.45700132031309676

Round[Mean[xd], 10.^-6] // InputForm

0.457001

But then, why would you round in the middle of your calculations?


Bob Hanlon

---- jihane <jihane.ajaja at mail.mcgill.ca> wrote: 

=============
Mr hanlon:

thank you very much for the help.
I tried to implement this in my code but i didn't succeed. If you would like to check my code and perhaps indicate to me how i could implement it in my code I would really appreciate:

<< PlotLegends`

(* Change Flight number in labelling *) 

SetDirectory[NotebookDirectory[]];

cutOffFreq = 20;
fileTime = 85;


(**********************USER INPUT***********************************)
\

(*Specify column numbers within text file to be extracted*)
fineTimeCol = 1;

X0Col = 6;
Y0Col = 7;
Z0Col = 8;

(*Total number of columns in the text file*)
numberOfColumns = 12;


(*For RMS plots*)
	(*Specify how often to calculate RMS values; i.e. every ___ seconds*)
\

	RMSseconds = 1;

(*For PSD plots*)
	(*Choose how often to integrate PSD plots to find RMS  contribution*)
\

	fileTime = 85;
	numSeconds = 60;
	



RawDataPlots = True;

(********************************************************************)


(*The samples are collected at 32Hz for a85 minute file*)

sampleFreq = 32;

(*Read data from file*)
data = Import["UofT_Nanowire_Flight1 - Copy.dat"];

listOfZeroes = Table[0, {i, numberOfColumns}];

(*Specify which columns to read*)
td =  ReplacePart[listOfZeroes, fineTimeCol -> 1];

x0d = ReplacePart[listOfZeroes, X0Col -> 1];
y0d = ReplacePart[listOfZeroes, Y0Col -> 1];
z0d = ReplacePart[listOfZeroes, Z0Col -> 1];

(*Split data into appropriate columns, drop "EndOfFile" at the end of \
the list*)


X0D = Drop[data.x0d, -1];
Y0D = Drop[data.y0d, -1];
Z0D = Drop[data.z0d, -1];


(********************************************************************************************************************)
\

(*Start analysis for each group of X, Y, Z*)
(********************************************************************************************************************)

(*Assign the X, Y, Z lists*)

XD = X0D;
YD = Y0D;
ZD = Z0D;

XDNew = {};
YDNew = {};
ZDNew = {};

LZ = Length[ZD];

For[j = 1, j <= LZ, j++;
  If[ZD[[j]] < 0.05, ZDNew = Append[ZDNew, ZD[[j]]]; 
   XDNew = Append[XDNew, XD[[j]]]; YDNew = Append[YDNew, YD[[j]]]];
  ];


(*xMean= mean of raw data rounded to 6 decimal places*)
xMean = N[Mean[XD], 6];
yMean = N[Mean[YD], 6];
zMean = N[Mean[ZD], 6];

xMeanNew = N[Mean[XDNew], 6];
yMeanNew = N[Mean[YDNew], 6];
zMeanNew = N[Mean[ZDNew], 6];

(*Demean the raw data*)
XDemeaned = XD - xMean;
YDemeaned = YD - yMean;
ZDemeaned = ZD - zMean;

XDemeanedNew = XDNew - xMeanNew;
YDemeanedNew = YDNew - yMeanNew;
ZDemeanedNew = ZDNew - zMeanNew;

(*Create list of course time based on number of data points and \
sample frequency*)
TD = (Range[Length[XD]] - 1)/sampleFreq;
TDNew = (Range[Length[ZDNew]] - 1)/sampleFreq;


(*Time interval*)
dt = TD[[2]] - TD[[1]];
dtNew = TDNew[[2]] - TDNew[[1]];


(******************Raw Data Plots************************************)

(*Plot raw data plots if specified*)
If[RawDataPlots,  
  (* 'time' is a list of numbers representing the time at which each \
data point was collected *)
  time = TD/60;
  timeNew = TDNew/60;
  
  
  (* 'XDV' is a two dimensional list represengting the voltage \
measurements versus time *)
  XDV = Transpose[{time, XD}];
  YDV = Transpose[{time, YD}];
  ZDV = Transpose[{time, ZD}];
  
  XDVNew = Transpose[{timeNew, XDNew}];
  YDVNew = Transpose[{timeNew, YDNew}];
  ZDVNew = Transpose[{timeNew, ZDNew}];
  
  
  (* The following exports plots of the acceleration data for each \
axis into the folder specified at the beginning of this file *)
  xName = "X-Axis Accelerometer Measurement.gif";
  yName = "Y-Axis Accelerometer Measurement.gif" ;
  zName = "Z-Axis Accelerometer Measurement.gif";
  
  xOut = StringForm["X-Axis Accelerometer Measurement - Flight 1"];
  yOut = StringForm["Y-Axis Accelerometer Measurement - Flight 1"];
  zOut = StringForm["Z-Axis Accelerometer Measurement - Flight 1"];
  
  Export[xName, 
   Framed[ListLinePlot[XDVNew, PlotRange -> All, 
     PlotLabel -> Style[xOut, 20], Frame -> True, 
     FrameLabel -> {"Time (min)", 
       "Measured Acceleration (g/\!\(\*SubscriptBox[\"g\", \
\"0\"]\))"}, LabelStyle -> Directive[15], ImageSize -> Scaled[1], 
     Axes -> False]]];
  Export[yName, 
   Framed[ListLinePlot[YDVNew, PlotRange -> All, 
     PlotLabel -> Style[yOut, 20], Frame -> True, 
     FrameLabel -> {"Time (min)", 
       "Measured Acceleration (g/\!\(\*SubscriptBox[\"g\", \
\"0\"]\))"}, LabelStyle -> Directive[15], ImageSize -> Scaled[1], 
     Axes -> False]]];
  Export[zName, 
   Framed[ListLinePlot[ZDVNew,  PlotRange -> All, 
     PlotLabel -> Style[zOut, 20], Frame -> True, 
     FrameLabel -> {"Time (min)", 
       "Measured Acceleration (g/\!\(\*SubscriptBox[\"g\", \
\"0\"]\))"}, LabelStyle -> Directive[15], ImageSize -> Scaled[1], 
     Axes -> False]]];
  ];




  • Prev by Date: Re: ListLinePlot with null value
  • Next by Date: Re: CONDITION/DATA ANALYSIS/PLOTS
  • Previous by thread: Re: CONDITION/DATA ANALYSIS/PLOTS
  • Next by thread: Re: CONDITION/DATA ANALYSIS/PLOTS