Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • 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
Joined
May 29, 2011
Messages
7
Location
CA
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.
 
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
 
Oh ok, i get it! Thanks a lot guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top