Hello, I am using ode45 to get the integration but keep getting errors. I am confused. The variables are x,y and s
Here is my code:
xyinit=[0;0];
[t,xy]=ode45(@uvfun,[1,9],xyinit);
function [uv]=uvfun(t,xy,s)
% consider n=19
n=19;
xi=[];
for i=1:n
xi=[xi,i/(n+1)];
end
% consider yi=0
yi=zeros(size(xi));
s=sym('s',[n,1]);
xy=sym('xy',[2,1]);
uv=zeros(size(xy));
uv=[1;0];
for i=1:n
uv=uv+[uv(1)+s(i)*(xy(1)-xi(i))/((xy(1)-xi(i))^2+(xy(2)-yi(i)^2));uv(2)+s(i)*(xy(2)-yi(i))/((xy(1)-xi(i))^2+(xy(2)-yi(i)^2))];
end
end

1 comentario

Star Strider
Star Strider el 28 de En. de 2018
The equations in the image do not appear to be ordinary differential equations.
You only need to do a summation for each.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 28 de En. de 2018

0 votos

ode45 calculates the integral numerically. You cannot provide the derivatives as symbolic variables.
Is u and v the derivative of your function or do you want to calculate a sum?

3 comentarios

Tianyu Zhou
Tianyu Zhou el 28 de En. de 2018
u,v are the given functions. And u=dx/dt, v=dy/dt. s is the unknown matrix. We want to find the plot of x and y.
Jan
Jan el 28 de En. de 2018
"s is the unknown matrix"? You cannot integrate a function numerically, which includes an unknown matrix. If you want a symbolic solution, you cannot plot x and y. So start with finding out, what you want to obtain.
Tianyu Zhou
Tianyu Zhou el 28 de En. de 2018
Ok thanks. So is there any other way to do this integration? ODE45 is not necessary. On the question, it asks me to integrate the function first, then using the function (after integration) to find what s is.

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 28 de En. de 2018

Comentada:

el 28 de En. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by