Hi,
Below psudo code for a C program took 66 sec. Same thing i tried to do in MATLAB (please find code below) it is much slower.Is it possible to run in same time as C.Please clarify this it will be very helpful.
Thanks,
Sita
psudo code for C
for(int i=0; i < 10; i++){ x[1] = 2.0 + drand48(); //x[2] = 2.0 + drand48(); for(int j=0; j < 30; j++){ x[2] = 2.0 + drand48(); x[3] = 2.0 + drand48(); //x[4] = 2.0 + drand48(); for(int k=0; k < 60; k++){ x[4] = 2.0 + drand48(); x[5] = 2.0 + drand48(); x[6] = 2.0 + drand48(); for(int l=0; l < 80; l++){ x[7] = 2.0 + drand48(); x[8] = 2.0 + drand48(); for(int m=0; m < 100; m++){ x[9] = 2.0 + drand48(); x[10] = 2.0 + drand48(); val = calc_func(x); if(val < min_so_far){ for(int p=1; p <= 10; p++){ best_comb[p] = x[p]; } min_so_far = val; } } } } } }
MATLAB Code:
clear;clc;ticcountm=0;n=1;s=1;for t=1:s for i=1:10 x1=min1 + ((max1 - min1)*rand(1)); for j=1:40 x2=min2 + ((max2 - min2)*rand(1)); x3=min3 + ((max3 - min3)*rand(1)); for k=1:60 x4=min4 +((max4 - min4)*rand(1)); x5=min5 +((max5-min5)*rand(1)); x6=min6 +((max6-min6)*rand(1)); for l=1:80 x7=min7+((max7-min7)*rand(1)); x8=min8 + ((max8 - min8)*rand(1)); for m=1:100 x9=min9+((max9-min9)*rand(1)); x10=min10+((max10-min10)*rand(1)); countm=countm+1 ; yal= fc10(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10); minvals( countm)=min(yal); end end end end end minofall=min(minvals) end toc
Best Answer