Array indices must be positive integers or logical values.

7 visualizaciones (últimos 30 días)
Error in TASKA (line 22)
A(t)=(A0-B0/YB)./(1-(B0/(YB*A0))*exp(-((YB*A0/B0)-1)*K*B0.*t));
  5 comentarios
Navaneetha Krishnan Murugadoss
Navaneetha Krishnan Murugadoss el 6 de Mzo. de 2022
my initial value is 0 and final value is 12 hours i need to find the value inbetwwen this time
David Hill
David Hill el 6 de Mzo. de 2022
Cannot help further unless you provide more information (all variables with values and context)

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 6 de Mzo. de 2022
A thorough discussion is in the FAQ:
In the meantime, try getting rid of (t) on the left hand side.
A = (A0-B0/YB) ./ (1-(B0/(YB*A0)) .* exp(-((YB*A0/B0)-1)*K*B0 .* t));

Navaneetha Krishnan Murugadoss
Navaneetha Krishnan Murugadoss el 6 de Mzo. de 2022
clc
clear all
YB=1;
YP=0.15;
A0=1;
B0=3;
P0=0;
K= 5E-5;
ti=0;
tf=12;
F=@(t,y)[-K*y(1)*y(2);-YB*K*y(1)*y(2);YP*K*y(1)*y(2)];
% create function of ODE
% f = [da/dt;db/dt,dp/dt]
[t,y]= ode89(F,[ti tf],[A0;B0;P0]);
%ODE89
A(t)=(A0-B0/YB)/(1-(B0/(YB*A0))*exp(-((YB*A0/B0)-1)*K*B0*tf));
% Analytical solution
plot(tf,y(:,1),'-0',tf,A_t','-*')
title('Solution of ODE with ODE89 and comparison with Analytical value');
xlabel('Time t');
ylabel('solution A(ODE89)& A(t) Analytical Value');
xlabel('Time t');
ylabel('solution A (ODE89) & A(t) Analytical value');
xlabel('Time t');
ylabel('Solution A(ODE89) & A(t) Analytical ');
legend('A(ODE89)','A(t) Analytical')
disp('time A(ODE89) A(t) Analytical ')
disp([tf y(:,1) A_t])
  3 comentarios
Navaneetha Krishnan Murugadoss
Navaneetha Krishnan Murugadoss el 6 de Mzo. de 2022
I tried using removing t in A but it shows
Error using plot
Invalid color or line style.
Error in TASKA (line 26)
plot(tf,y(:,1),'-0',tf,A,'-*')
Walter Roberson
Walter Roberson el 6 de Mzo. de 2022
plot(rand(1,5), '-o')
plot(rand(1,5), '-O')
plot(rand(1,5), '-0')
Error using plot
Invalid color or line style.
which is to say that your '-0' is dash-zero and that is not a recognized line style or color. Using dash-oh or dash-capital-oh is fine.

Iniciar sesión para comentar.

Categorías

Más información sobre Functions en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by