To get Better perfom for a Function

4 vues (au cours des 30 derniers jours)
sarngon
sarngon le 13 Avr 2015
Hello everyone,
I wrote a code for a function that includes inner functions and integral but I get confused I is working but not a professional way can you help me to write it more professional ? Thank you :)
aa=(k*l*vi/(wr*ccons));
bb=@(w) (((1+w/wr*l)*vi/ccons).^(k-1));
cc=@(w) (2.71.^((-((1+w/wr*l)*vi/ccons)).^k));
f3 =@(w)bb(w).*cc(w);
for i=1:num;
dd=@(w)kr*(x1(i)-w);
dd2=@(w)kr*(x2(i)-w);
fw1 =@(w)f3(w).*dd(w);
fw2=@(w)f3(w).*dd2(w);
% x=in(:,3:4);
% Qscalarx = @(x)integral(@(w) kr*(in(:,3:4)-w)*(k*l*vi/(wr*ccons))*(((1+w/wr*l)*vi/ccons).^(k-1))*2.71.^((-((1+w/wr*l)*vi/ccons)).^k),0,x);
% Q = @(x)arrayfun(Qscalarx,x);
% Q(x);
Q1(i) = integral(fw1,0,x1(i));
% fw2 = @(w) kr*(x2(i)-w)*(k*l*vi/(wr*ccons))*(((1+w/wr*l)*vi/ccons).^(k-1))*2.71.^((-((1+w/wr*l)*vi/ccons)).^k);
Q2(i) = integral(fw2,0,x2(i));
end
Q=Q1'+Q2';
Cwsum=dc(1)*(in(:,3))+dc(2)*(in(:,4));
lam=abs(Pd+2.32-sum(in(:,1:4)'))';
totalcost=Cthermal+(Q)+Cwsum+100*lam;
Thank you :)

Réponses (0)

Catégories

En savoir plus sur Linear Algebra dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by