2 Answers

  1. Andrew- Reply

    2019-11-13

    Well, if I understand you correctly then:

    x = sum((1:10).^2);
    

    should do the trick.

  2. Andy- Reply

    2019-11-13

    You will first declare i as a vector containing the values over which you will sum.

    i=1:10;
    

    Then you simply sum the vector of the squares:

    sum(i.^2)
    
    ans =  385
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>