×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*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.

Students Click Here

Jobs

Matlab Matrix Initialization

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.
 

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  

peace
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.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources