Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Error using ==> mpower........ Matrix must be square.

Subject: Error using ==> mpower........ Matrix must be square.

From: Mark L. J.

Date: 10 Jan, 2013 04:53:41

Message: 1 of 7

top of the day all

please could someone guide me through solving this error

thanks and best wishes


%%Create a data set:

X = rand(100,1)*4-2;
A = rand(100,1)*4-2;
B = rand(100,1)*4-2;
F=1.10471*X^2*A+0.04811*B*(14.0+A);

%%%%Construct the interpolant:

G = TriScatteredInterp(X,A,B,F);

%%%%Evaluate the interpolant at the locations (qx, qy).
%% The corresponding value at these locations is qz:

ti = -2:.25:2;
[qX,qA,qB] = meshgrid(ti,ti,ti);
qF = G(qX,qA,qB);
mesh(qX,qA,qB);
hold on;
plot3(X,A,B,F,'o');


.............command error
??? Error using ==> mpower
Matrix must be square.

Error in ==> triscastdmeshgrid10012013b at 6
F=1.10471*X^2*A+0.04811*B*(14.0+A);

Subject: Error using ==> mpower........ Matrix must be square.

From: Roger Stafford

Date: 10 Jan, 2013 06:14:12

Message: 2 of 7

"Mark L. J." <abejohno@gmail.com> wrote in message <ba35e7b1-e79a-47b4-8dd2-f902982f812d@googlegroups.com>...
> ??? Error using ==> mpower
> Matrix must be square.
> Error in ==> triscastdmeshgrid10012013b at 6
> F=1.10471*X^2*A+0.04811*B*(14.0+A);
- - - - - - - - - -
  The error message is telling you what is wrong. You wrote X^2 where X is not a square matrix. If you were to write X*X you would also get an error message. If you want to simply square each element of X you should write X.^2.

Roger Stafford

Subject: Error using ==> mpower........ Matrix must be square.

From: Mark L. J.

Date: 10 Jan, 2013 06:25:28

Message: 3 of 7

On Thursday, January 10, 2013 8:14:12 AM UTC+2, Roger Stafford wrote:
> "Mark L. J." wrote in message <ba35e7b1-e79a-47b4-8dd2-f902982f812d@googlegroups.com>...
>
> > ??? Error using ==> mpower
>
> > Matrix must be square.
>
> > Error in ==> triscastdmeshgrid10012013b at 6
>
> > F=1.10471*X^2*A+0.04811*B*(14.0+A);
>
> - - - - - - - - - -
>
> The error message is telling you what is wrong. You wrote X^2 where X is not a square matrix. If you were to write X*X you would also get an error message. If you want to simply square each element of X you should write X.^2.
>
>
>
> Roger Stafford


thanks so much R Stafford

I got another error wrt dimensions. Please help. thanks for the time

??? Error using ==> mtimes
Inner matrix dimensions must agree.

Error in ==> triscastdmeshgrid10012013b at 6
F=1.10471*X.^2*A+0.04811*B*(14 + A);

Subject: Error using ==> mpower........ Matrix must be square.

From: Roger Stafford

Date: 10 Jan, 2013 06:40:14

Message: 4 of 7

"Mark L. J." <abejohno@gmail.com> wrote in message <62702ec8-e9a0-425a-84a8-17b3355b56c8@googlegroups.com>...
> ??? Error using ==> mtimes
> Inner matrix dimensions must agree.
> Error in ==> triscastdmeshgrid10012013b at 6
> F=1.10471*X.^2*A+0.04811*B*(14 + A);
- - - - - - - - -
It's almost the same problem. You can't do matrix multiplication of two 100 x 1 vectors and that is what "*" without the dot calls for. Use ".*" instead for multiplying element by element.

Roger Stafford

Subject: Error using ==> mpower........ Matrix must be square.

From: Mark L. J.

Date: 10 Jan, 2013 07:17:02

Message: 5 of 7

On Thursday, January 10, 2013 8:40:14 AM UTC+2, Roger Stafford wrote:
> "Mark L. J." wrote in message ...
>
> > ??? Error using ==> mtimes
>
> > Inner matrix dimensions must agree.
>
> > Error in ==> triscastdmeshgrid10012013b at 6
>
> > F=1.10471*X.^2*A+0.04811*B*(14 + A);
>
> - - - - - - - - -
>
> It's almost the same problem. You can't do matrix multiplication of two 100 x 1 vectors and that is what "*" without the dot calls for. Use ".*" instead for multiplying element by element.
>
>
>
> Roger Stafford

thanks so much again...

I now have a blank graph(no specific output) been generated and with the error as shown below.

I really want to plot this function F with at least the 3 variables while I keep the other fourth variable constant. thanks

................................................................

??? CData must be an M-by-N matrix or M-by-N-by-3 array

Error in ==> graph3d.surfaceplot.surfaceplot>localConstructor at 136
h = graph3d.surfaceplot(argin{:});

Error in ==> graph3d.surfaceplot.surfaceplot at 7
h = localConstructor(varargin{:});

Error in ==> mesh at 162
                hh = graph3d.surfaceplot(x,y,z,'FaceColor',fc,'EdgeColor','flat', ...

Error in ==> triscastdmeshgrid10012013b at 28
mesh(qX,qA,qB);
.............................................................

Subject: Error using ==> mpower........ Matrix must be square.

From: Roger Stafford

Date: 10 Jan, 2013 07:34:16

Message: 6 of 7

"Mark L. J." <abejohno@gmail.com> wrote in message <c00a190e-83da-4c81-808f-392a066b5d9c@googlegroups.com>...
> Error in ==> graph3d.surfaceplot.surfaceplot>localConstructor at 136
> h = graph3d.surfaceplot(argin{:});
>
> Error in ==> graph3d.surfaceplot.surfaceplot at 7
> h = localConstructor(varargin{:});
>
> Error in ==> mesh at 162
> hh = graph3d.surfaceplot(x,y,z,'FaceColor',fc,'EdgeColor','flat', ...
>
> Error in ==> triscastdmeshgrid10012013b at 28
> mesh(qX,qA,qB);
- - - - - - - -
Mark, I think it is time you started solving some of these problems yourself.

Roger Stafford

Subject: Error using

From: Mark L. J.

Date: 10 Jan, 2013 07:57:29

Message: 7 of 7

On Thursday, January 10, 2013 9:34:16 AM UTC+2, Roger Stafford wrote:
> "Mark L. J." wrote in message ...
>
> > Error in ==> graph3d.surfaceplot.surfaceplot>localConstructor at 136
>
> > h = graph3d.surfaceplot(argin{:});
>
> >
>
> > Error in ==> graph3d.surfaceplot.surfaceplot at 7
>
> > h = localConstructor(varargin{:});
>
> >
>
> > Error in ==> mesh at 162
>
> > hh = graph3d.surfaceplot(x,y,z,'FaceColor',fc,'EdgeColor','flat', ...
>
> >
>
> > Error in ==> triscastdmeshgrid10012013b at 28
>
> > mesh(qX,qA,qB);
>
> - - - - - - - -
>
> Mark, I think it is time you started solving some of these problems yourself.
>
>
>
> Roger Stafford



thanks R. Stafford

I am a little bit new to MATLAB that is the reason. Of course the learning curve for me now is slow and steady. The reason I am asking is that I have spent almost all night trying to solve it. Nevertheless, thanks for the tips you have given me. Do have a great day.

One last question is what is the best parameters to plot a 4-variable functions like mine -
F=1.10471*X.^2*A+0.04811*B*(14 + A);

thanks

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us