MATLAB: I am trying to plot this function dxdt=N0*si​n(omega*t)​*x*(1-x/K) to get a 3-D plot but the code does not work,where is the error

meshgrid

function RunOsciliationsky3D
N0all= 1:1:10;
N=length(N0all);
omegaall= 1:1:10;
M=length(omegaall);
Pmax=zeros(1,N);
Pmean=zeros(1,N);
Pall=[Pmax(i),Pmean(j)];
x=length(Pall);
for i=1:N
for j =1:N
[t,x]=ode45(@osciliation,[0 100],0.1,[],N0all(i),10,omegaall(j));
Pall(i,j)=x;
end
end
[N0x,omegay]=meshgrid(N0all,omegaall);
h=mesh(N0x,omegay,Pall);
1;
Note: x axis = Noall
y axis =omegaall
z axis = Pall, which is a matrix containing the maximum and mean values of x.

Best Answer

It is not necessary to call on 'ode45' to solve this particular differential equation. By ordinary methods of calculus, integration of both sides of
dx/(x*(1-x/K)) = N0*sin(omega*t)*dt
will give you
x/(K-x) = C*exp(-N0/omega*cos(omega*t))
where C is a constant whose value depends on the given initial condition. All you have to do then is put in those initial conditions for x and t to solve for C, and then solve the equation for x to obtain x as an explicit function of t involving the parameters N0 and omega. With this explicit formula you should be able to do whatever plotting you have in mind.