Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matlab Matrix Initialization

Status
Not open for further replies.

akaballa

Computer
May 29, 2011
7
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

Recommended for you

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).
 
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
 
One line:

ndgrid=zeros(m,n);

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

[peace]
Fe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor