From: Mike Schalla on 8 Feb 2010 13:04 Hi, I need to plot the volume of a sphere (V=(4/3)pir^3) with the radius bounds being from .1 to 10. Everytime I run it I always get this error. I just can't get it to work so please help x = .1:.1:10; y= x^3*pi*4/3; plot(x,y) ??? Error using ==> mpower Matrix must be square. -mike
From: Steven Lord on 8 Feb 2010 13:15 "Mike Schalla" <mschalla18(a)gmail.com> wrote in message news:ebafed88-8142-49c3-9295-a188a03ca74b(a)m31g2000yqb.googlegroups.com... > Hi, > I need to plot the volume of a sphere (V=(4/3)pir^3) with the radius > bounds being from .1 to 10. Everytime I run it I always get this > error. I just can't get it to work so please help > > x = .1:.1:10; > y= x^3*pi*4/3; > plot(x,y) > > ??? Error using ==> mpower > Matrix must be square. You're only raising one matrix to a power here. Is that matrix square? No, it isn't. x^3 is essentially equivalent to x*x*x and for that multiplication to be defined, x must be square. Now x.^3, on the other hand, is essentially equivalent to x.*x.*x and all that requires is that x exist. The * operator perform matrix multiplication; the .* operator performs elementwise multiplication. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
Pages: 1 Prev: CSVREAD issue: How to treat characters? Next: finding nearest value in 2D arrays |