Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Index out of bounds error need helpthank you

  1. Aug 13, 2009 #1
    Dear forummers,

    I'm trying to solve a problem that is displayed in matlab below:-

    ??? Attempted to access x(2); index out of bounds because numel(x)=1.

    Error in ==> fit_fun at 5
    Fit_fun_val= x(1)^2 + x(2)^2 + x(3)^2;

    Error in ==> jack_immune at 47
    Sel_Ab_cri(ksel)=fit_fun(Ini_Ab(:,ksel));

    I understand that (Ini_Ab(:,ksel)) has to have 3 numbers/datas, but the coding is looping.
    How am i able to modify the code as to have 3 numbers as well as a loop? Sorry for my poor explanation.

    Part of the code is as below:-

    for ksel=1:pop_size
    Sel_Ab_cri(ksel)=fit_fun(Ini_Ab(:,ksel));
    end

    Thanks in advance.
    PS: Do let me know if i need to post the full code. Thanks.
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Index out of bounds error need helpthank you
  1. Matlab: out of bounds. (Replies: 2)

Loading...