Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: matrix dimensions must agree.....

Subject: matrix dimensions must agree.....

From: KA

Date: 23 Jun, 2008 15:10:19

Message: 1 of 3

Hi!

So, I am just starting to use matlab and I have come across
an error that I do not know how to handle.
Here is the whole picture:
I have 2 cells.
N which is 2222x23
and A which is 2222x1
A and N are made up of 4x4 matrices
I want to compare the two like this:
for i=1:2222
for j=1:23
if N{i,j}-A{i}==0, A{i}=[], end
end
end
HOWEVER, every time it says
error- Matrix dimensions must agree.
But both cells contain 4x4 matrices....so the dimensions do
agree.
I have changed A to a 2222x23 cell filling the rest of the
spaces with [].
But it still came up with the same error.
So i dont know what to do. Or if there is another way that i
can compare the two cells.
thank you for any sort of help in advance!!!


Subject: matrix dimensions must agree.....

From: Roger Stafford

Date: 23 Jun, 2008 16:34:01

Message: 2 of 3

"KA " <kmcdon03@uoguelph.ca> wrote in message <g3oecr$t5u
$1@fred.mathworks.com>...
> So, I am just starting to use matlab and I have come across .....

  If, for any value of i you encounter a j for which N{i,j}==A{i}, then when you
compare N{i,j+1} and A{i} they will be of different sizes since you will have set A
{i} to []. That will give you the error message. You need to break out of the
inner for-loop whenever A{i} is set to [] to avoid this happening.

Roger Stafford


Subject: matrix dimensions must agree.....

From: KA

Date: 23 Jun, 2008 17:00:21

Message: 3 of 3

thank you very much!!


"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
wrote in message <g3oj9p$qur$1@fred.mathworks.com>...
> "KA " <kmcdon03@uoguelph.ca> wrote in message <g3oecr$t5u
> $1@fred.mathworks.com>...
> > So, I am just starting to use matlab and I have come
across .....
>
> If, for any value of i you encounter a j for which
N{i,j}==A{i}, then when you
> compare N{i,j+1} and A{i} they will be of different sizes
since you will have set A
> {i} to []. That will give you the error message. You
need to break out of the
> inner for-loop whenever A{i} is set to [] to avoid this
happening.
>
> Roger Stafford
>
>

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics