Вам не нужен цикл для создания матрицы для расчетов.Ниже приведен пример создания матриц и построения графиков.Это может быть не совсем то, что вы ищете, но это должно приблизить вас.
% set up values to calc for for u,v,w in [0,1]
stepsize = 0.1;
u = 0:stepsize:1; % min, step, max
v = 0:stepsize:1;
w = 0:stepsize:1;
% now set up combined tables
u = u';
v = v';
w = w';
uv = [repmat(u, length(v),1), repmat(v, length(u),1)];
uw = [repmat(u, length(w),1), repmat(w, length(u),1)];
% now do calcs
% note u-vector is uv(:,1) or uw(:,1), depending upon the combo, etc.
x = uv(:,1) .* cos(2 * pi * uv(:,2));
y = uv(:,1) .* sin(2 * pi * uv(:,2));
z = sqrt(1 - uw(:,1) .^2) .* (2 * uw(:,2) -1);
% it's not clear what you want to plot, but here are some examples
figure
hold on
subplot(4,1,1)
plot(x, y, 'Color', 'green', 'DisplayName', 'XY');
box on
title('Your Title Here', 'FontSize', 10)
xlabel('X', 'FontSize', 8)
ylabel('Y', 'FontSize', 8)
set(legend, 'Location', 'best')
subplot(4,1,2)
plot(x, z, 'Color', 'blue', 'DisplayName', 'XZ');
box on
title('Your Title Here', 'FontSize', 10)
xlabel('X', 'FontSize', 8)
ylabel('Z', 'FontSize', 8)
set(legend, 'Location', 'best')
subplot(4,1,3)
plot(y, z, 'Color', 'red', 'DisplayName', 'YZ');
box on
title('Your Title Here', 'FontSize', 10)
xlabel('Y', 'FontSize', 8)
ylabel('Z', 'FontSize', 8)
set(legend, 'Location', 'best')
subplot(4,1,4)
plot3(x, y, z, 'Color', 'magenta', 'DisplayName', 'XYZ');
box on
grid on
ax = gca;
ax.GridAlpha = 0.5;
title('Your Title Here', 'FontSize', 10)
xlabel('X', 'FontSize', 8)
ylabel('Y', 'FontSize', 8)
zlabel('Y', 'FontSize', 8)
set(legend, 'Location', 'best')
Выше приведено это число: