Finding specific data point x for given y

2 views (last 30 days)
Julianne Korn
Julianne Korn on 19 Nov 2019
Answered: darova on 20 Nov 2019
Here is my code, it works and the graph is correct. However, i am having trouble answering one of my questions about this code. I need to find the CB and CS values at t=5, as well as i need to find the t and CB values when CS = 0.001. I cannot figure out the codes to find those answers.
t = [0 50]; %time interval
Y0 = [0.05 5]; % initial values
[tout, Yout] = ode15s(@func20,t,Y0)
plot(tout,Yout)
xlabel('t')
ylabel('C')
legend('CB','CS')
title('HW 10 - Part4 ODE15s')
function dy = func20(t,x)
Kr = 0.30000;
K = 0.00300;
CB = x(1);
CS = x(2);
dy = zeros(2,1);
dy(1) = ((Kr)*(x(1))*(x(2)))/(K+x(2));
dy(2) = ((-0.75)*(Kr)*(x(1))*(x(2)))/(K+x(2));
end

Answers (1)

darova
darova on 20 Nov 2019
  • I need to find the CB and CS values at t=5
Use interp1 to find
  • i need to find the t and CB values when CS = 0.001
Use fsolve or fzero
FCS = @(x) interp1(tout,CS,x)-0.001;
t001 = fsolve(FCS,tinit); % try: tinit = 15

Community Treasure Hunt

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

Start Hunting!