MATLAB: Does changing the order of the multiplication yield different graphs

graphMATLABparametricsurface

I was doing an activity where I had to use parametric equations to graph the surface formed by revolving the curve about the x-axis. I first did it like this:
>> u=linspace(0,1,50);
>>v=linspace(0,2*pi,50);
>>[U,V]=meshgrid(u,v);
>>X=(3*(U-1/3).^2)*cos(V);
>>Y=(3*(U-1/3).^2)*sin(V);
>>Z=U;
>> surf(X,Y,Z)
And got the strange graph, with very strange bounds:WrongGraph.jpg
When I switched the order of multiplication in the X and Y parametric equations, to put the trig first:
>> u=linspace(0,1,50);
>>v=linspace(0,2*pi,50);
>>[U,V]=meshgrid(u,v);
>>X=cos(V)*(3*(U-1/3).^2);
>>Y=sin(V)*(3*(U-1/3).^2);
>>Z=U;
>>surf(X,Y,Z)
The graph was exactly what I was looking for:GoodGraph.jpg
Can anybody help me understand why the order of multiplication gives me a different result? Thanks.

Best Answer

a*b~=b*a % don‘t forget the rules of matrix multiplication
change * to .* element wise operation you will get the same result