Matlab taking over an hour to run project

4 views (last 30 days)
I'm am currently doing a project about windturbines. I have to use several loops within each other. When I try to run the project, it takes forever to get an answer! When I try to debug step by step, everything seems to go well. The variables all have a reasonable value. I do however use two 1x360 matrices (these are the CW180 en CW300) and one 1x29 matrix (rotor). I did not include them here in the question but as you can see the loops have to walk trough all those values. Anyone an idea what might take this long? is it the use of matrices that are too big? I did that before and it worked perfectly...
clearvars koppel pitch P
a=-1;
acc=-1;
k=0;
kacc=0;
Pmax=0;
thetap=1:1:29;
for theta= 1:1:29;
for i=1:1:29;
a=-1;
acc=-1;
k=0;
kacc=0;
r=rotor(i,1);
twist=rotor(i,4);
c=rotor(i,2);
thick=rotor(i,3);
if i == 1;
dr = r;
else
dr = r - rotor(i-1,1);
end
while(abs(k-a)>0.00001);
a=k;
Y=round(a);
% idem voor a' (=acc)
acc=kacc;
Z=round(acc);
phi=atand((15*(1-a))/(((18*2*pi)/60)*r*(1+acc)));
alfa=(phi)-(theta)-((twist*pi)/180);
if alfa<0;
alfa=alfa+360;
end
Cl180=interp1(cW180(:,1),cW180(:,2),alfa);
Cd180=interp1(cW180(:,1),cW180(:,3),alfa);
Cl300=interp1(cW300(:,1),cW300(:,2),alfa);
Cd300=interp1(cW300(:,1),cW300(:,3),alfa);
thicktypes=[0.18;0.30;1];
Cl=[Cl180;Cl300;0];
Cd=[Cd180;Cd300;0.89];
L=interp1(thicktypes,Cl,thick);
D=interp1(thicktypes,Cd,thick);
Fn=((3*c)/2)*1.22*(((15)*((1-a)))/(sind(phi)))^2*(L*cosd(phi)+D*sind(phi))*dr;
Q=3*(c/(2))*1.22*(((15)*((1-a)))/(sind(phi)))^2*(L*sind(phi)-D*cosd(phi))*r*dr;
syms f;
assume(f,'clear');
T= 4*f*(1-f)*1.293*(15^2)*(pi*r);
eqn1 = Fn==T;
EQN1 = abs(solve(eqn1,f));
p=double(EQN1(1,1));
syms facc;
assume(facc,'clear');
KU= 4*facc*(1-p)*1.293*15*(108)*(r^3)*pi;
eqn2 = Q==KU;
EQN2 = abs(solve(eqn2,facc));
pacc=double(EQN2(1,1));
k=p;
kacc=pacc ;
end
P(i)=Q*((18*2*pi)/60);
end
Koppel(theta)=trapz(P);
pitch(1,theta)=theta;
% bereken Pmax, en de bijhorende pitchhoek
if Koppel(theta) > Pmax;
Pmax = Koppel(theta);
pitch(1,theta)=theta;
end
end
plot(pitch,Koppel,'r-');
title('pitchpowercurve');
xlabel('pitchhoek (graden)');
ylabel('vermogen P (Watt)');
  1 Comment
the cyclist
the cyclist on 4 Jan 2016
Can you upload the data in a MAT file? I tried to run your program with some random data, and it gave an error.

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 4 Jan 2016
Do you know how to profile your code?
  2 Comments
Pieter Haesevoets
Pieter Haesevoets on 4 Jan 2016
Well I do not! I will most certainly give it a try! thanks.
the cyclist
the cyclist on 4 Jan 2016
No problem. By the way, the best form of thanks is to upvote and/or accept an answer, which rewards the contributor and can point future users to useful answers.

Sign in to comment.

More Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!