function X=constT(V,Y)
%defining parameter%
%defining parameter%
global A1 A2 E1 E2 Fa0 Cn2 Co2 T0 deltaCp Cpn2 Cpo2 Cpno Hrxn R Ua Ta
R =8.314;
A1=.04;
A2=.1;
E1=42; % forward activation energy
E2=16000; % backward activation energy
Cn2=1; % feed concentration
Co2=1;
Fa0= Cn2 + Co2;
T0=500 ; % feed temperature
Cpn2 =29.7198; Cpo2=29.051; Cpno =29.3018; %j/mol.K
deltaCp = 2*Cpno-Cpo2-Cpno;
Hrxn = 180.5; % kj/mol at refrence temp 300K
Ua =0.01;
Ta =550;
x=Y(1);
T=Y(2);
ra=A1*exp(-E1/(8.314*T))*(Cn2^2)*((1-x)^2)*((T0/T)^2); % change this
% -ra (correct this)
X(1,1) = ra/Fa0; % X
X(2,1) = (-ra*Hrxn - Ua*(T-Ta))/(Fa0*(Cn2*Cpn2+Co2*Cpo2)); % Temperature T
end
Error message:
constT
Not enough input arguments.
Error in constT (line 22)
x=Y(1);
%code for solving and plotting the ode's:
global Fa0;
Fa0=2;
[Vv,Yv]=ode45('constT',[0:500],[0;500]);
f1=figure;
f2=figure;
f3=figure;
figure(f1);
plot(Vv,Yv(:,1))
hold
grid
title('X vs Volume')
xlabel('Volume')
ylabel('X')
hold off
figure(f2);
plot(Vv,Yv(:,2))
hold
grid
title('T vs Volume')
xlabel('Volume')
ylabel('T')
hold off
% calculating -ra
for i =1:501
ra(i)=Fa0*(Yv(i,1)/Vv(i));
end
figure(f3);
plot(Vv,ra)
hold
grid
title('-ra vs V')
xlabel('Volume')
ylabel('-ra')
hold off

댓글 수: 2

Voss
Voss 2021년 12월 4일
You've showed the code for the function constT, but the error is in var2. Can you post the code for var2?
And I agree with @KSSV that the error is most likely caused by running the function via F5 or the Run button, which runs it with no input arguments.
Sujay Bharadwaj
Sujay Bharadwaj 2021년 12월 4일
i am sorry i renamed var2 as constT but the error message is from before that

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2021년 12월 4일
편집: KSSV 2021년 12월 4일

0 개 추천

It looks like you are running the code without giving the required inputs by hitting f5 or run button. No you should not. You should define the input variables to the function and then call the function in a code or in worskapce.
V = value ; % define V here
Y = value ; % define Y here ;
% Now call the function
X = constT(V,Y) ;
While calling the function see to it that, your are in the folder where function is saved or function is added to the path.

댓글 수: 1

Sujay Bharadwaj
Sujay Bharadwaj 2021년 12월 4일
This is just the function definition. I don't expect it to print anything. It just stores two ODES ,the latter half of my code is for calling this function where i have set values for V and Y mentioned. I'll add the other half of the code too the question .

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2021년 12월 4일

편집:

2021년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by