Using a Subroutine to Create a Plot
Show older comments
I have the following subroutine which takes a point with radius 1 and then finds a velocity vector at that point.
p = [0.282 0 0.959]'; %specify point where velocity is to be evaluated%
[v]=StokesletVelocity(N,sing,p,Kn,f);
function[v]=StokesletVelocity(N,sing,p,Kn,f)
for i=1:N
rij= (p - sing(1:3,i));
FF(1:3, 3*i-2:3*i) =((1/(8*pi*Kn))*((eye(3)/norm(rij)) + (rij*rij')/norm(rij)^3))'; %subroutine to find velocity at the point %
end
v=FF*f;
end
What I would like to do is plug in points to the subroutine with a range of radii going from 1 to 10 and get velocities for all of them. I was thinking of doing this in steps of 0.2 at a time, so the next p to plug into the subroutine would be
[0.2*0.282 0 0.2*0.959]
the next would be
[0.4*0.282 0 0.4*0.959]
and so on up until a radius of 10. This will produce an array of velocity vectors and I then need to find the radial component for each one and plot the radial component of each velocity vector against the corresponding value for the radius ie. the number which is mutliplying the numbers in the position vector for the point. Is it possible to use the subroutine I have to generate the array of velocity vectors and then plot radial component against radius in this way? Let me know if it is not clear what I mean.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!