Creating a Linear System with a Double Loop
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am dealing with a system where I have one sphere inside of a larger one and I work with the radial vector for the distance between the outer shell and the inner shell. I have nodes spaced equally around the outer shell and there is the same number of nodes corresponding to the outer nodes with exactly the same spacings on the inner shell.
For a outer node, I have to evaluate a function which produces a scalar which goes into the first element of a matrix as A. The function has as its input the magnitude of the radial vector for the distance from the outer node to one of the inner nodes, and I then have to sum the contributions when I evaluate the function inputting the distance from the outer node to each of the inner nodes (so if I chose 10 nodes on the outer shell, that's 10 terms for the 1 outer node and the distance from it to the 10 corresponding inner nodes). Then, there is a second function (also just depending on the distance from the outer to the inner node) to get the element B, and another to get element C for the first row of the matrix (really the same function every time but for the Cartesian components of a force vector). A further 6 functions at the outer node give us the next two rows of the matrix, so we end up with a system of 3 linear equations when combined with the boundary conditions.
The aim is then to repeat this for every outer node to create a system of 3N equations. I think there is a brute force way of doing this where you loop over all the outer nodes, and then loop over each inner node for every outer node, but I was wondering if there is a more efficient way of doing this and building the matrix, as it seems like trial and error to somehow get the dimensions of everything to line up correctly. I can explain in more detail if necessary or post bits of the code if that helps, if anyone can help I would appreciate it as I am getting into a mess with this.
4 Commenti
darova
il 13 Mar 2019
A those circles have one center or they have eccentric?
If you have radial distance, how do you know which vector is that? Do you have dimension those spheres?
r = 5;
d = 2;
a = linspace(0,pi,100);
D = sqrt( r*r+(r+d)^2-2*r*(r+d)*cos(a) );
plot(a,D)
m = mean(D);
s = trapz(a,D)/(a(end)-a(1)); % dividing by pi
m/s*100
Risposte (0)
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!