using ode45 to find streamline
显示 更早的评论
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 个评论
Star Strider
2018-1-28
The equations in the image do not appear to be ordinary differential equations.
You only need to do a summation for each.
回答(1 个)
Jan
2018-1-28
0 个投票
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 个评论
Tianyu Zhou
2018-1-28
Jan
2018-1-28
"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
2018-1-28
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!