1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help with matrix in m file

  1. Dec 5, 2007 #1
    I'm trying to write an m-file in matlab that can count how many data point in a vector are zero, how many are 1, etc. I can call the vector and get the length, max and min values, but I also need to be able to call each element seperatly and I can't figure out how to do this. I've been playing around and this is what i have:

    function len (A)
    N= length(A);
    M =max(A);
    for i=1:N


    MAX =M

    But it says expression (A=[i,1]=0) is incomplete. I've tried a few other expressions but none work. Any help is appreciated.
  2. jcsd
  3. Dec 5, 2007 #2
    When you reference an element in Matlab, you use parenthesis, if I remember correctly. So you'd need to reference A(i,1).
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Help with matrix in m file
  1. Octave: M-Files (Replies: 3)