From: Brendan on
Hi,
I have a 1110x4 array and want to find the row in which a certain condition is satisfied..
For example if I have:
Y=[y1;y2;y3;y4] where y1,y2,y3,y4 are 1110 long vectors,
I want to find the row in which:
atan2(y1/y2)==certain value.

I can find the row for Max and Min using [C,I]=min(Y) etc but am not sure how to check if the atan2 condition is satisfied.
Any ideas? Im sure its relatively easy but...
Thanks
Brendan
From: Matt Fig on
"Brendan " <c_uboid88(a)hotmail.co.uk> wrote in message <hpib30$9s4$1(a)fred.mathworks.com>...
> Hi,
> I have a 1110x4 array and want to find the row in which a certain condition is satisfied..
> For example if I have:
> Y=[y1;y2;y3;y4] where y1,y2,y3,y4 are 1110 long vectors,
> I want to find the row in which:
> atan2(y1/y2)==certain value.
>
> I can find the row for Max and Min using [C,I]=min(Y) etc but am not sure how to check if the atan2 condition is satisfied.
> Any ideas? Im sure its relatively easy but...
> Thanks
> Brendan


Some things are not right about your post. First of all, if y1-4 are 1110 element vectors, then Y CANNOT be 11104-by-4 as given. Second, atan2 takes 2 arguments. I think you should clarify these things.
From: Brendan on
Sorry, I just meant that the columns of Y contain 1110 elements. i.e It is an array with 4 colums and 1110 rows. Does that not make sense?
And the atan2 is used because I need to find the row at which atan of y2/y1 equals a certain angle. y1 and y2 are the x and y co-ordinates of a particle respectively. So yes, I know it needs two arguments, those arguments are the values of y1 and y2 at each row! So I need the code to go through each row and check when atan2(y2/y1)==value and then tell me which row of Y this occurs in.
I hope this clarifies?
Brendan
From: us on
"Brendan " <c_uboid88(a)hotmail.co.uk> wrote in message <hpicc5$64$1(a)fred.mathworks.com>...
> Sorry, I just meant that the columns of Y contain 1110 elements. i.e It is an array with 4 colums and 1110 rows. Does that not make sense?
> And the atan2 is used because I need to find the row at which atan of y2/y1 equals a certain angle. y1 and y2 are the x and y co-ordinates of a particle respectively. So yes, I know it needs two arguments, those arguments are the values of y1 and y2 at each row! So I need the code to go through each row and check when atan2(y2/y1)==value and then tell me which row of Y this occurs in.
> I hope this clarifies?
> Brendan

a small example of ML code would be worth so much more than this verbose description...

us
From: Brendan on
y0 = [1;0;0;1];
t0=0
tend=.1
step=tend/0.01

for i=1:100
[t,y]=ode45(@function,[0:0.01:tend],y0,options);
x(1:length(y))=y(:,1);
y(1:length(y))=y(:,2);
xdot(1:length(y))=y(:,3);
ydot(1:length(y))=y(:,4);

y0=[y(step,1);y(step,2);y(step,3);y(step,4)]; % sets the last values calculated to
% new initial conditiosn
end
Y=[x,y,xdot,ydot]

so I want to find the row of Y at which atan2(y/x)==somevalue


Thanks again