Summation of function handles in cell array
Afficher commentaires plus anciens
Hi. I have written the following code so far.
par.comp = 2;
par.NT = 9;
par.P = 1;
par.Asat=[4.92531 4.6543 ];
par.Bsat=[1432.526 1435.264];
par.Csat=[-61.819 -64.848];
ics = [ 5.0000 0.2545 0.2545 0.2545 0.2545 0.6295 0.6295 0.6295 5.0000
4.9810 0.2535 0.2476 0.2289 0.1834 0.3066 0.1780 0.0469 0.0238
0.0190 0.0010 0.0069 0.0256 0.0711 0.3229 0.4515 0.5826 4.9762]';
for i = 1:par.comp
Psat{i} = @(T) 10.^(par.Asat(i)-par.Bsat(i)./(par.Csat(i)+T));
y{i} = @(T,x) x*Psat{i}(T)/par.P;
end
xn = bsxfun(@rdivide,ics(:,2:end),ics(:,1));
for i = 1:par.NT
T(i) = fzero(@(T) y{1}(T,xn(i,1))+y{2}(T,xn(i,2))-1,300);
end
The code works as it is supposed to (I think :) ), but I need it to be expandable for a higher value of par.comp. If par. comp is for instance 3 (ics would be 4x9), I need the last for loop to be:
for i = 1:par.NT
T(i) = fzero(@(T) y{1}(T,xn(i,1))+y{2}(T,xn(i,2))+y{3}(T,xn(i,3)-1,300);
end
And so on. Is there any way to do this?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Segmentation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!