"matt reister" <mattreister@hotmail.com> wrote in message
<fgikbk$95t$1@fred.mathworks.com>...
> What i am doing is transforming the unit circle 11 times
> under a given transform then plotting it each time. However
> i am haveing a hard time plotting all 11 transforms. I have
> been stuck on this problem for days and my teacher wont
> help. It seems like it would be really easy but i cant
> figure it out. Here is my code and more detail:
>
> M = [ 1.5, 0; 0, 1];
> c = [2; 0; ];
> theta=[1:100]/100*2*pi;
> x=cos(theta);
> y=sin(theta);
> vNew = [x; y;];
> M2 = [cos(pi/5), sin(pi/5); sin(pi/5), cos(pi/5);];
>
> for i = 1:11
>
> for n = 1:100
>
> vNew(:,n) = M*M2*vNew(:,n) + M2*c;
>
> end
>
> plot(vNew(1,:),vNew(2,:));
>
> end
>
>
> It seems to me that the transform is working fine, but it
> seems that when it goes through the plot sequence the last
> plot overides the previos plot. I need all eleven plots
> including the original vector vNew to be ploted on the same
> graph. What would be the easyest way to go about doing this?
Add
figure
hold on
before the loop. This creates a new figure and turns on the hold property, so
that plots are superimposed and don't replace old ones. If instead of "hold on"
you use "hold all", the colors of the curves will be automatically changed.
hth
Lorenzo
