for loop forward modelling
Afficher commentaires plus anciens
Hi there, I am not very good at matlab but need to include this equation in my project, I want to test values of z to see what best fits with the model, but I need to write out the equation first, with sums and loops? Not sure where to begin other than
% pre-defined constants:
x1 = -100;
x2 = 100;
y1 = -100;
y2 = 100;
G = 6.67E-11; % assign the gravitation constant to G
rho = -2600; % assign the density of surrounding rock to rho
%the equation
Yi_for = zeros(x1,1);
for i = 1:2
for j = 1:2
for k = 1:2
Yi_for(i) =
2 commentaires
Torsten
le 30 Mar 2022
Not sure what (x_p,y_p,z_p) is.
Can you clarify ?
Casey Kelly-Weekes
le 30 Mar 2022
Réponses (2)
Sulaymon Eshkabilov
le 30 Mar 2022
You can start working somewhat in this way:
...
rho = 2600; % Note density can't be negative.
for ii = 1:2
for jj = 1:2
for k = 1:2
mu(ii,jj,k)=((-1)^ii)*((-1)^jj)*((-1)^k);
dx(ii)=
dy(jj)=
dz(k)=
...
end
end
end
% pre-defined constants:
x(1) = -100;
x(2) = 100;
y(1) = -100;
y(2) = 100;
z(1) = -100;
z(2) = -200;
xp = 0;
yp = 0;
zp = 0;
G = 6.67E-11;
delta_rho = 2000;
g_z = 0.0;
for i = 1:2
dxi = x(i) - xp;
for j = 1:2
dyj = y(j) - yp;
for k = 1:2
muijk = (-1)^i * (-1)^j * (-1)^k;
dzk = z(k) - zp;
Rijk = sqrt( dxi^2 + dyj^2 + dzk^2 );
g_z = g_z + ...
muijk * (dzk * atan(dxi * dyj / (dzk * Rijk)) - ...
dxi * log(Rijk + dyj) - ...
dyj * log(Rijk + dxi) );
end
end
end
g_z
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
