Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

216 views
Skip to first unread message

Mark L. J.

unread,
Jan 9, 2013, 11:53:41 PM1/9/13
to
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);

Roger Stafford

unread,
Jan 10, 2013, 1:14:12 AM1/10/13
to
"Mark L. J." <abej...@gmail.com> wrote in message <ba35e7b1-e79a-47b4...@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

Mark L. J.

unread,
Jan 10, 2013, 1:25:28 AM1/10/13
to Roger Stafford
On Thursday, January 10, 2013 8:14:12 AM UTC+2, Roger Stafford wrote:
> "Mark L. J." wrote in message <ba35e7b1-e79a-47b4...@googlegroups.com>...
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);

Roger Stafford

unread,
Jan 10, 2013, 1:40:14 AM1/10/13
to
"Mark L. J." <abej...@gmail.com> wrote in message <62702ec8-e9a0-425a...@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

Mark L. J.

unread,
Jan 10, 2013, 2:17:02 AM1/10/13
to
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);
.............................................................

Roger Stafford

unread,
Jan 10, 2013, 2:34:16 AM1/10/13
to
"Mark L. J." <abej...@gmail.com> wrote in message <c00a190e-83da-4c81...@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

Mark L. J.

unread,
Jan 10, 2013, 2:57:29 AM1/10/13
to
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
0 new messages