Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Par for

Subject: Par for

From: Saad

Date: 24 Aug, 2011 14:41:30

Message: 1 of 1

Dear All,

I have a function called " example1". I would like to evaluate it accross 9 grids until the ratio of the current value over the previous value is between 0.98 and 1.05. Please look the code below:

%%9 dimensional grid

grid1D=[-10:1:10; -10:1:10; -10:1:10; -10:1:10; -10:1:10; -10:1:10; -10:1:10; -10:1:10; -10:1:10];

x=[ 1, 2 3, 4, 5 ,6 ,7 ,8, 9];


for k=1:9



 for k=1:8
     if (j >=0.98) & (j <=1.05)
 for i=1:21



[j1, idx]=min(h)


   for i=1:21



[j2, idx]=min(h);


The function "example1" takes approximately 12 hours to run thats why I would like to use parfor. Now I dont know in which loop it is the most efficient to place it in my code above? Any comment would be very helpful. Thanks a lot


Tags for this Thread

What are tags?

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.

Contact us