Calculation of streamline length (Line object)

4 views (last 30 days)
Hi everybody,
I explain you my problem : Given a matrix of density current (Jx,Jy), I want to calculate the distance of the streamline for each point of my matrix. To do so, I already write the following code :
for i=1:ny
for j=1:nx
h=streamline(X,Y,Jx,Jy,(j-1)*dx,(i-1)*dy);
distanceCurrent(i,j)=sum(sqrt(diff(get(h,'Xdata')).^2+diff(get(h,'Ydata')).^2));
end
end
Where, dx dy are the gridstep and nx ny the number of point. This works well but it takes a lot of time. To improve the running time, I wanted to do the following :
H=streamline(X,Y,Jx,Jy,X,Y)
which gives me an array of line objects. But I cannot do the same as before because get(H(i),'Xdata') for all i returns 0.
Do you have any idea to improve my code or another way to calculate the length of a streamline?
Thank you very much

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!