×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Matlab Matrix Initialization

## Matlab Matrix Initialization

(OP)
Hi,

I am a newbie in matlab.  I am trying to initialize an empty matrix with certain dimensions.

#### CODE

X = 1:5;
Y = 1:1;
[X, Y] = ndgrid(x, y);
tabuList = [X,Y];
for i = 1:5
tabuList(i,1) = 'EMPTY';
end
However, I get the following error

#### CODE

??? Undefined function or variable 'x'.

I m not sure why it is not recognizing x and y.  Can some let me know of the proper initialization technique.

Replies continue below

### RE: Matlab Matrix Initialization

In the third line, it should be:

[X, Y] = ndgrid(X, Y);

I think the problem is that MATLAB is looking for the variable 'x', whereas you've initiated 'X' (remember MATLAB is case sensitive).

### RE: Matlab Matrix Initialization

Kinda odd really.  ML started its life as a wrapper around some very old FORTRAN functions, yet its founders decided to be case sensitive.

- Steve

### RE: Matlab Matrix Initialization

One line:

ndgrid=zeros(m,n);

% here m, and n are the dimensions of the empty matrix directly

Fe

### RE: Matlab Matrix Initialization

(OP)
Oh ok, i get it! Thanks a lot guys!

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!