Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Eric
Posts:
5
Registered:
9/7/12


Categorize rows of matrix
Posted:
Mar 19, 2013 8:31 PM


Hi,
I am working on categorizing a 100x5 matrix that I am calling coupling. Each row contains a coupling angle (gamma) 0:360 degrees and the columns are trials. The coupling angles are broken into four phases based on a polar plot: gamma = [0:360];% Can I define gamma like this? inphase == 22.5 <= gamma < 67.5, 202.5 <= gamma < 247.5; distal_phase == 67.5 <= gamma < 112.5, 247.5 <= gamma < 292.5; outphase == 112.5 <= gamma < 157.5, 292.5 <= gamma < 337.5; prox_phase == 0 <= gamma < 22.5, 157.5 <= gamma < 202.5, 337.5 <= gamma < 360;
Furthermore the rows of the matrix coupling are broken down into 4 bins: bin1 = coupling(1:20,trial number) bin2 = coupling (21:50, trial number) bin3 = coupling(51:75, trial number) bin4 = coupling(76:100, trial number)
I need to loop through each trial and determine the frequency of coupling angle value defined by 1 of my four phases within each bin. For example, in bin1 I could have 25 coupling angles that falls into inphase and zero for the remaining three phases.
I don't know how to find and sum the number of coupling angles that falls within a bin for each trial.
Any suggestions are much appreciated.
Thank you,
Eric
coupling is a (100,5) matrix bin = [bin1;bin2;bin3;bin4]; gamma = [0:360]; for trial = 1:5 for row = 1:100 for bin_num = 1:bin if bin == 1 bin1 = coupling(row:20,trial); inphase == 22.5 <= gamma < 67.5, 202.5 <= gamma < 247.5; distal_phase == 67.5 <= gamma < 112.5, 247.5 <= gamma < 292.5; outphase == 112.5 <= gamma < 157.5, 292.5 <= gamma < 337.5; prox_phase == 0 <= gamma < 22.5, 157.5 <= gamma < 202.5, 337.5 <= gamma < 360; elseif bin == 2 bin2 = coupling(21:50,trial); elseif bin == 3 bin3 = coupling(51:75,trial); elseif bin ==4 bin4 = coupling(76:100,trial); else xx = ('bin error') end end end end



