# How to generate code in MATLAB for randomly oriented short fibers?

10 vues (au cours des 30 derniers jours)
RAJESH le 27 Fév 2023
Modifié(e) : RAJESH le 21 Mar 2023
How to generate code in MATLAB for randomly oriented short fibers?
##### 2 commentairesAfficher AucuneMasquer Aucune
Jan le 27 Fév 2023
Please add any details: 2D or 3D? Do the "fibers" have a specific shape? Is there an outer limit?
RAJESH le 27 Fév 2023
I want to generate RVE code for short fibre for random oorientations

Connectez-vous pour commenter.

### Réponses (1)

Meet le 6 Mar 2023
Hi,
Generating code in MATLAB for randomly oriented short fibers typically involves defining the geometry of the fibers and randomly assigning their orientation.
Here's one approach to generate randomly oriented short fibers in MATLAB:
1.Define the length and diameter of the fibers:
fiber_length = 10; % length of the fibers (in microns)
fiber_diameter = 1; % diameter of the fibers (in microns)
2.Generate a random number of fibers:
num_fibers = randi([10, 100], 1); % generate a random integer between 10 and 100
3.Generate random positions for the fibers within a square region:
region_size = 100; % size of the square region (in microns)
fiber_positions = rand(num_fibers, 2) * region_size; % generate random positions within the region
4.Generate random orientations for the fibers:
fiber_orientations = rand(num_fibers, 1) * pi; % generate random angles between 0 and pi
5.Generate the coordinates of the fiber endpoints:
fiber_endpoints = [fiber_positions, fiber_positions + fiber_length * [cos(fiber_orientations), sin(fiber_orientations)]];
6.Generate a plot of the fibers:
figure;
hold on;
for i = 1:num_fibers
plot(fiber_endpoints(i, [1, 3]), fiber_endpoints(i, [2, 4]), 'k-', 'LineWidth', fiber_diameter);
end
axis equal;
axis([0, region_size, 0, region_size]);
This code will generate a plot of randomly oriented fibers with random positions and a random number of fibers. You can adjust the parameters (such as the size of the region or the range of the random number of fibers) to suit your needs.
For generating random fibers inside a box, please refer Generate Fiber - File Exchange - MATLAB Central (mathworks.com)
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
RAJESH le 21 Mar 2023
Modifié(e) : RAJESH le 21 Mar 2023
its fine but my doubt is that, those fibre should be collapase with each other, all should have random position and random direction with approximate 40 to 60 % volume fraction.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Visualization dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by