# MATLAB: Saving Loop Values to Array with Non-Integer Index

arraysindexingindexing loopsloopsMATLAB

Hi All,
I'm trying to save the results of the iteration loop to an array for plotting, "r" and "x" specifically. My issue is that I can't figure out what to use as an index. My code is below, PLEASE HELP!
``R = 0.6;b = 0.1;ro = R*b;a = asind(b);function [pl] = Geodesic(R, b, ro, a)% This function plots a geodescic contour% Initial Conditionsw = 0;r = R;x = 0;Dr = 0;Dx = 0;Dw = 1;hold onfor w = 0:Dw:90        rm = r / ( cosd(w) * (2-tand(a).^2) );    r(w) = r - Dr;    x(w) = x + Dx;        a = asind(ro/r);    Dx = rm * Dw*cosd(w);    Dr = rm * Dw * sind(w);        pl = plot(r(w),x(w),'k.');    title('Geodesic Dome Contour');    xlabel('Distance From Center');    ylabel('Y Position');    endend``

``function [pl,r,x] = Geodesic(R, b, ro, a)% This function plots a geodescic contour% Initial Conditionsw = 0;r = R;x = 0;Dr = 0;Dx = 0;Dw = 1;hold onfor w = 0:Dw:90    rm = r / ( cosd(w) * (2-tand(a).^2) );    r(w) = r - Dr;    x(w) = x + Dx;    a = asind(ro/r);    Dx = rm * Dw*cosd(w);    Dr = rm * Dw * sind(w);    pl = plot(r(w),x(w),'k.');    title('Geodesic Dome Contour');    xlabel('Distance From Center');    ylabel('Y Position');endend``