main code :
clear all a=0; b=10;N=10; y0=0; h=(b-a)/N; t(1)=a;R(1)=1;Pg(1)=1;P1(1)=1;c(1)=12;for n=1:N; t(n+1)=t(n)+h; c(n+1)=c(n)+h*g(t(n),c(n)); Pg(n+1)=1.9*g(t(n),c(n)); P1(n+1)=8*R(n); R(n+1)=R(n)+h*f(t(n),R(n)) ;endplot(t,R)
function g:
function g=g(t,c)g=(45*c)/74;
function f:
function f=f(t,R)f=(((Pg-P1)*R)/152)-60;
this is the result:
Error :Undefined function or variable 'Pg'Error in f (line 2)f=(((Pg-P1)*R)/152)-60
how can I asign the variable Pg and P1 to the equation in the main code
Best Answer