Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am learning to use the atan2 function in Matlab. I have a matrix S12 that is 2xdata_size. I am taking the data from the S12 matrix and finding the angle phi12 between points a and b (rows 1 and 2). I am trying to collect the all the phi12 in a matrix and want to histogram plot the information.

This is what I have so far:

 load('S12.mat');
 data_size = 10;
 Phi12 = zeros(1,data_size);
 nbins = 40;
 for m = 1:data_size;
     a = S12(1,:);   
     b = S12(2,:);                   
     r12 = sqrt(a.^2 + b.^2);        
     phi12 = atan2(b/r12,a/r12);     
     Save_Phi12(:,m) = phi12;        
 end
 h = figure();
 Phi12hist = [nbins,Phi12(1,:)];      
 title('Phi12HIST');
 saveas(Phi12HIST,strcat([namefigs,'Phi12HIST']),'fig')

Up to the end of the loop the code works. I am not getting a plot though. And, I need to throw two more loops in that represent S13-->phi13 and S23-->phi23.

Any help, thoughts, suggestions would be greatly appreciated as always! :)
(I'm trying to get this done by tomorrow)

Thanks! Lanae

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.