Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Anonymous
Anonymous asked in Education & ReferenceHomework Help · 1 decade ago

Help me out with a MATLAB question?

Write MATLAB progtram to find the following sum with for (or while) loop or by vectorization programming.

S= 1 - 1/3 + 1/5 - 1/7 + ... - 1/1003

1 Answer

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    See this with just a few elements... to understand the logic behind

    % elements to take into account

    n = 1 : 2 : 9

    % find appropriate signs

    t = ones(1, length(n));

    t(2 : 2 : length(n)) = -1

    % see terms

    v = t./n

    % sum terms

    sum(v)

    Do that with n up to 1003

    I suggest you see: http://www.matrixlab-examples.com/series-and-seque...

    .

Still have questions? Get your answers by asking now.