Having each iteration of nested loop plot on graph
Mostrar comentarios más antiguos
I have a test script of a much larger script for one nested loop. The nested loop uses 3 different vectorized variables to find a Radius, then using the same variables and the new radius, determine a value. The value is summed for each possible combination of x and y for a given z. I wish to plot that summed value, the the loop will return to z and pick a new z, where the sum is reset. Once each z has been used, the plot should show the summed value at each z recorded on a single plot. When I use the loop, I am only getting the final value of sigma, and nothing plotted. Can someone figure out why my nested loop is failing?
clear;clc;
gamma = 95;
zwater = 0;
H = 10;
TYP = 1;
x = 8;
v = 0.49;
array = 2;
arraysize = 6;
Q = 250;
Q = (Q/array^2);
nax = array;
nay = array;
sum =0;
xmin = x - arraysize/2;
xmax = x + arraysize/2;
yleft = -(arraysize/2);
yright = (arraysize/2);
z = 0:0.1:H;
xa = linspace(xmin+(1/(2*array)*arraysize),xmax-(arraysize/(2*array)),nax);
ya = linspace(yleft+(1/(2*array)*arraysize),yright-(arraysize/(2*array)),nay);
for zii = z
sum =0;
for xii = xa
for yii = ya
R = sqrt(xii^2+yii^2+zii^2);
sigprimeh = ((Q/(R*pi))*((3*zii*xii^2)/R^3)*((R*(1-2*v))/(R+zii)));
sum = sum +sigprimeh;
figure()
end
end
plot(sigprimeh,z)
title('Stress Due to Surcharge Load')
xlabel('\sigma`h (ksf)');
ylabel('Depth "z"(ft)');
set(gca,'YDir','reverse')
hold on
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!