Use quiver () function to plot vector field (xy plane) of O2 flux in lab5.

6 views (last 30 days)
What I have currently:
rt= 50; % in micrometers
mu= 3.75*10.^8; %in mPa
delta_p= 1000; %delta p mmHg/um
l= 200; %length of the vessel (0-200 um)
v= ((rt.^2)/4.*u).*delta_p.*(1-(r/rt).^2); %velocity of vessel
x=linspace(0,200,20); % x points for the meshgrid
y=linspace(-rt,rt,-200); %y point for the meshgrid
%graph selection
[X, Y]=meshgrid (x,y);
vrx=blood(Y,rt,mu,delta_p);
U=Vrx;
V=U;
V(:,:)=0;
%vrx=v;
figure (1)
quiver(X,Y,u,v);
%part b graphing
%velocity of blood function
function [Vrx]=blood(r,rt,mu,delta_p)
Vrx=((rt^2)./(4*mu))*delta_p*(1-r/rt.^2);
end
What I had for Lab 5:
function[j]=lab05(x0,y0)
syms x y;
%muscle cell radius (R) - um - 1*10^-6m
R=25*(10^(-6));
%diffusion coeff(D) - cm^2*s^-1 - (1*10^-2m)^2*s^-1
D=(10^(-5))*(10^(-4));
%oxygen concentration outside cell (co2)0 - mol O2*mL^-1
co2=2.22*(10^(-7));
%oxygen consumption rate (sigma)- mole*mL^-1*s^-1
sigma=1.65*10^-8;
%oxygen concentration equation(phi)
phi=((sigma*(R^2))/4*D)*((((x^2)+(y^2))/(R^2))-1)+co2;
rtest= (x0^2)+(y0^2);
if rtest < (R)^2
disp('Will Work')
else
rtest > (R)^2; disp('Wont Work')
end
gradphi=gradient(phi,[x,y]);
%diffusing oxygen flux equation(j)
j=-D*gradphi;
jr0=subs(j,{x,y},{x0,y0});
divergence(j,[x,y])-phi;
disp('Flux of diffusing oxygen:') end

Answers (1)

Simran
Simran on 3 Apr 2025 at 4:52
Hello @Joy Odigbo,
To plot the vector field “O2 flux” using the MATLAB’s “quiver()” function, you can follow these steps:
1.) Create a meshgrid of x and y points within the region of interest. I took it as "within the muscle cell radius(R)", where R = 25
x = linspace(-R, R, 20);
y = linspace(-R, R, 20);
[X, Y] = meshgrid(x, y);micrometers.
2.) Now, use your "lab05" function logic to calculate the oxygen flux at each grid point.
% Calculating oxygen flux
D = (10^(-5)) * (10^(-4)); % Diffusion coefficient
sigma = 1.65e-8; % Oxygen consumption rate
co2 = 2.22e-7; % Oxygen concentration outside cell
R = 25e-6; % Muscle cell radius
% Oxygen concentration equation
phi = ((sigma * (R^2)) / (4 * D)) * (((X.^2 + Y.^2) / R^2) - 1) + co2;
% Calculating gradient
[phi_x, phi_y] = gradient(phi, x, y);
% Calculating flux
Jx = -D * phi_x;
Jy = -D * phi_y;
3.) Now, use the "quiver()" function to plot the flux vectors on the grid.
figure;
quiver(X, Y, Jx, Jy);
xlabel('x (um)');
ylabel('y (um)');
title('Oxygen Flux Vector Field');
axis equal;
Following these steps I got this figure:
You can refer to these documentations for more information:

Categories

Find more on Vector Fields 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!