MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayNew to MATLAB?
MATLAB Central > MATLAB Newsreader > if A&&B else optimization and profile question 

Subject: if A&&B else optimization and profile question From: Louis Date: 15 Oct, 2010 13:51:03 Message: 1 of 9 
Hello all, 
Subject: if A&&B else optimization and profile question From: Cris Luengo Date: 15 Oct, 2010 14:59:04 Message: 2 of 9 
"Louis " <wlouis@ryerson.ca> wrote in message <i99m87$brn$1@fred.mathworks.com>... 
Subject: if A&&B else optimization and profile question From: Jan Simon Date: 15 Oct, 2010 15:22:06 Message: 3 of 9 
Dear Louis, 
Subject: if A&&B else optimization and profile question From: Louis Date: 15 Oct, 2010 15:31:04 Message: 4 of 9 
Thank you so much Cris for your help. I am trying to vectorize the forloop as advised, i hope it can be vectorized. 
Subject: if A&&B else optimization and profile question From: Louis Date: 15 Oct, 2010 15:34:04 Message: 5 of 9 
Thank you very much Jan. I posted a miniversion of the operation :) 
Subject: if A&&B else optimization and profile question From: Louis Date: 15 Oct, 2010 16:11:04 Message: 6 of 9 
"Louis " <wlouis@ryerson.ca> wrote in message <i99s9c$q75$1@fred.mathworks.com>... 
Subject: if A&&B else optimization and profile question From: Louis Date: 15 Oct, 2010 17:12:04 Message: 7 of 9 
> N(ANDED==1)=A(sub2ind(size(A),y(ANDED==1),x(ANDED==1))) 
Subject: if A&&B else optimization and profile question From: Louis Date: 15 Oct, 2010 17:52:03 Message: 8 of 9 
Here is a bigger bunch of the code and that shows how many times sub2ind i am using. Based on the profile report, each line is iterated for about 59000 times. also A in my case is a matrix of size 24x24... 
Subject: if A&&B else optimization and profile question From: Louis Date: 15 Oct, 2010 17:58:04 Message: 9 of 9 
Sorry i forgot the code 
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.