31 views (last 30 days)

I am having a bit of a issue extracting data to show how the fluence varies through the medium vertically. I have a horizontal line, but want to get a vertical line. Could anyone help. I have attatched the script and figures for more information. Could anyone suggest how to get a vertical line extracted?

Code:

% A code to show an Isotropic Light Source traveling through a Medium of

% Oxygenised Blood. The source code has been taken from

% https://inverselight.github.io/ValoMC/simpletest.html and has been

% adapted for the project - Referenced in report.

% This example demonstrates how to setup a simple photon transport

% simulation, run it and visualise the result.

%% Create a triangular mesh

% Function createRectangularMesh is used to setup a simple triangular mesh. The

% mesh is visualised in the figure below. Each element (a triangle) and

% boundary element (a line) in the mesh has a unique index that can be

% used to set their properties. The indices of the boundary elements are

% shown in the figure.

xsize = 10; % width of the region [mm]

ysize = 10; % height of the region [mm]

dh = 0.1; % discretisation size [mm]

vmcmesh = createRectangularMesh(xsize, ysize, dh);

%% Set up Optical Parameters for Oxygenised Blood

% The Optical Parameters have been taken from literature values and have

% been cited within the report.

% Wavelength of light at 900nm

vmcmedium.absorption_coefficient = 0.56; % absorption coefficient [1/mm]

vmcmedium.scattering_coefficient = 68.86; % scattering coefficient [1/mm]

vmcmedium.scattering_anisotropy = 0.9824; % anisotropy parameter g of

% the Heneye-Greenstein scattering

% phase function [unitless]

vmcmedium.refractive_index = 1.615; % refractive index [unitless]

%% Create a Direct light sources from Boundary 4:7

% Photons are launched in the same direction.

vmcboundary.lightsource(20:80) = {'direct'};

%% Run the Monte Carlo simulation

% Use the parameters that were generated to run the simulation in the mesh.

solution = ValoMC(vmcmesh, vmcmedium, vmcboundary);

%% Plot the solution using MATLAB

figure(1);

hold on;

patch('Faces',vmcmesh.H,'Vertices',vmcmesh.r,'FaceVertexCData', solution.element_fluence, 'FaceColor', 'flat', 'EdgeColor', 'none');

xlabel('[mm]');

ylabel('[mm]');

c = colorbar;

title('Fluence [W/mm^2]');

hold off

%% Extracting Fluence to plot curve (Horizontal Line)

figure(2);

linetest = solution.element_fluence;

A = linetest;

B = A(50:100:end,:);

plot(B);

xlim([1 100]);

title('Variation in Fluence (W/mm^2) versus distance travelled (mm)')

xlabel('Distance travelled by Photons (mm)')

ylabel('Fluence (W/mm^2)')

%% Extracting Fluence to plot curve (Veritcal Line)

figure(3);

linetest = solution.element_fluence;

A = linetest;

B = A(50:100:end,:);

plot(B);

xlim([1 100]);

title('Variation in Fluence (W/mm^2) versus distance travelled (mm)')

xlabel('Distance travelled by Photons (mm)')

ylabel('Fluence (W/mm^2)')

Figure to show Light Source Travelling through Medium:

Figure to show Horizontal data line at (-5,0) to (5,0) to show how fluence intensity changes with depth penetration:

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

Start Hunting!
## 5 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1272569

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1272569

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1272589

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1272589

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1272644

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1272644

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1272709

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1272709

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1278098

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/721274-extracting-vertical-data-line-from-plot#comment_1278098

Sign in to comment.