Guest User

Untitled

a guest
Sep 19th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.07 KB | None | 0 0
  1. clear all
  2. format long
  3. for i=1:1000; %Trial Counter
  4.      rail=1:2400; %each .01 inch segmant of rail
  5.      glove1=unidrnd(2400-409);
  6.      glove2=unidrnd(2400-409);  %Picking a spot from 1 to the last element the glove can be on while still covering the rail.  I wasn't sure if only a fraction of the glove could hit it or not.
  7.      glove3=unidrnd(2400-409);
  8.      glove4=unidrnd(2400-409);
  9.  
  10.         for k=1:length(rail);
  11.             if glove1==rail(k);
  12.               rail(glove1:glove1+409)=NaN;
  13.                 elseif glove2==rail(k);
  14.               rail(glove2:glove2+409)=NaN;
  15.                 elseif glove3==rail(k);  %Scans through and sets all values where glove touches rail=NaN
  16.               rail(glove3:glove3+409)=NaN;
  17.                 elseif glove4==rail(k);
  18.               rail(glove4:glove4+409)=NaN;
  19.              else    
  20.             end
  21.         end
  22.        
  23.      rail(isnan(rail))=[];    %Deletes touched segments (marked as NaN)
  24.      untouchedspots(i)=length(rail);  %Counts untouched elements left of the current trial
  25. end
  26. Untouched=mean(untouchedspots)/2400
Add Comment
Please, Sign In to add comment