Prev: Update
Next: parfor on 2009b
From: gunther on 17 Jul 2010 10:03 Hello! I would like to do the following: A=zeros(2) is a predefined 2*2 matrix I want to fill this matrix to indicate the frequencies of 4 different events whose occurrence is evaluated in the course of a conditional statement that is nested in a for loop for i=1:10 if event_1 ==1 add 1 to A(1,1) elseif event_2 ==1 add 1 to A(1,2) elseif event_3 ==1 add 1 to A(2,1) else add 1 to A(2,2) end end e.g. A= 3 4 2 1 would state that event_1 occurred 3 times, event_2 4 times, etc. How can I do this while keeping the for loop as well as the conditional statement? I would be glad if you could help me with this Many thanks! forben
From: us on 17 Jul 2010 10:08 "gunther " <forben(a)web.de> wrote in message <i1sd6n$ado$1(a)fred.mathworks.com>... > Hello! > > I would like to do the following: > > A=zeros(2) is a predefined 2*2 matrix > > I want to fill this matrix to indicate the frequencies of 4 different events whose occurrence is evaluated in the course of a conditional statement that is nested in a for loop > > for i=1:10 > > if event_1 ==1 > > add 1 to A(1,1) > > elseif event_2 ==1 > > add 1 to A(1,2) > > elseif event_3 ==1 > > add 1 to A(2,1) > > else > > add 1 to A(2,2) > > end > > end > > > e.g. A= 3 4 > 2 1 would state that event_1 occurred 3 times, event_2 4 times, etc. > > How can I do this while keeping the for loop as well as the conditional statement? > > I would be glad if you could help me with this > Many thanks! > forben
From: us on 17 Jul 2010 10:09 "gunther " <forben(a)web.de> wrote in message <i1sd6n$ado$1(a)fred.mathworks.com>... > Hello! > > I would like to do the following: > > A=zeros(2) is a predefined 2*2 matrix > > I want to fill this matrix to indicate the frequencies of 4 different events whose occurrence is evaluated in the course of a conditional statement that is nested in a for loop > > for i=1:10 > > if event_1 ==1 > > add 1 to A(1,1) > > elseif event_2 ==1 > > add 1 to A(1,2) > > elseif event_3 ==1 > > add 1 to A(2,1) > > else > > add 1 to A(2,2) > > end > > end > > > e.g. A= 3 4 > 2 1 would state that event_1 occurred 3 times, event_2 4 times, etc. > > How can I do this while keeping the for loop as well as the conditional statement? > > I would be glad if you could help me with this > Many thanks! > forben why don't you have the courtesy to see what people told you here http://www.mathworks.com/matlabcentral/newsreader/view_thread/287115 before mindlessly posting the same OP, again... us
|
Pages: 1 Prev: Update Next: parfor on 2009b |