1. Limited time only! Sign up for a free 30min personal 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!

Homework Help: Matlab help

  1. Mar 1, 2013 #1
    I have everything correct, that is when I put in a value for n=10 I get the right results however I want to enter in more than one number at a time to give me three different results like a vector like [ 10 20 30] but I am just clueless as to how to go about this. the dots are there because i thought if i did that it might treat it the input as vector but i guess not I am stuck.I've tried using array addressing such as n(1,:) took me forever to get this far i just cant get past this bump. please help.

    n=input('Enter the number of terms as a vector:');
    for k=0:1:n

    fprintf('\n the diffrence between the series and pi is:%i\n\n',j)
    fprintf('\n the diffrence: %g\n\n',j)
    Report Post Edit/Delete Message
  2. jcsd
  3. Mar 1, 2013 #2
    that last fprintf line i have deleted do not pay it any attention.
  4. Mar 4, 2013 #3
    Isn't a nested loop necessary here? Your outer loop would iterate over your input vector while the inner loop gives you your operation results for each entry in n. Just save your results to a multidimensional array and it should all work, right?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted