How to evaluate a cell array of handle functions

Hi guys,
Sorry, I am quite new in Matlab and I am having a really hard time to get what I want. I developed a cell array of handle functions. The script looks like:
N=4
C=cell(1,N);
syms n Ea R r pO2 T t A
Arrhenious=sym(zeros(1,N));
for k=1:N
Arrhenious(k)=1-(1/((1/(n-1)+(exp(-Ea/(R*T))*A*t*((pO2)^r)))*(n-1))^(1/(n-1)));
C{k}=matlabFunction(Arrhenious(k));
end
Now, I need to evaluate each handle function for the syms parameters. There is not problem for n Ea r R PO2 and A as they are constant and the same for each handle function. The problem is that each handle function depends on Temperature and time. Each handle function must be evaluated at different temperature for the whole range of time. Therefore, T and t are vectors. These are T=[798 823 908 943] a temperature for each function handle and t=60:60:53940.
How could I evaluate each handle function in the cell array for the require temperatures and times with the rest of the parameters as constants?
Thank you in advance.
Best regards,
Cruz

 채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 1일

0 개 추천

You can write your code, like this. This also avoid syms and makes your code faster.
T = [798 823 908 943];
t = 60:60:53940;
N = length(T);
% since these are constants define them first. No need to define as sym, it
% will makw your code fast.
n = 1;
Ea = 1;
R = 1;
r = 1;
pO2 = 1;
A = 1;
output = cell(1,N);
theEquation = @(t, T) 1-(1./((1./(n-1)+(exp(-Ea./(R*T))*A.*t*((pO2).^r)))*(n-1)).^(1./(n-1)));
output{1} = theEquation(t, T(1));
output{2} = theEquation(t, T(2));
output{3} = theEquation(t, T(3));
output{4} = theEquation(t, T(4));
First, you need to correct the value of the constants.

추가 답변 (1개)

Cruz Hergueta
Cruz Hergueta 2018년 5월 1일

0 개 추천

Thank you very much. It works perfectly fine.
Thanks a lot!!!

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

질문:

2018년 5월 1일

댓글:

2018년 5월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by