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:
strange error message,please help

Subject: strange error message,please help

From: andy chen

Date: 11 Feb, 2009 02:48:02

Message: 1 of 3

Sir
  when I import dataset and run,I will get this below error message,I don't know why,can you help to solve,I put some codes to verity...
??? Error using ==> plus
Matrix dimensions must agree.

==========================
load glass.mat
data=glass;
center_num=6;
data_num=size(data,1);
data_dim=size(data,2);
dim=center_num*data_dim;

Subject: strange error message,please help

From: Image Analyst

Date: 11 Feb, 2009 03:09:01

Message: 2 of 3

andy chen
Set a breakpoint on the last line. Since center_num is a scalar (6), data_dim must also be a scalar. I don't see why it's not. I also don't see why it's complaining about the "plus" operation when you aren't adding anything (at least not explicitly). That's why you need to se a break point and look in the workspace to see if you're getting what you expect, for example data and glass should be a 2D matrix and data_num should be a scalar and data_dim should be a scalar.
Good luck,
ImageAnalyst

Subject: strange error message,please help

From: Roger Stafford

Date: 11 Feb, 2009 03:33:02

Message: 3 of 3

"andy chen" <andy5741@ms14.hinet.net> wrote in message <gmte92$c5q$1@fred.mathworks.com>...
> Sir
> when I import dataset and run,I will get this below error message,I don't know why,can you help to solve,I put some codes to verity...
> ??? Error using ==> plus
> Matrix dimensions must agree.
>
> ==========================
> load glass.mat
> data=glass;
> center_num=6;
> data_num=size(data,1);
> data_dim=size(data,2);
> dim=center_num*data_dim;

  Perhaps you have some other function or a variable named 'size' which is being accidentally called by matlab instead of its builtin 'size' function.

Roger Stafford

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