A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

Can anyone please help me to write this matlab m-file? Here is the pseudocode : http://oi53.tinypic.com/u1pvc.jpg

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    function y=lgrng(x,y,i,j) sum = 0 ; while i = 0,n product = yi; while j = 0,n if a ~= b then product = product * ( x - xj ) / (xi - xj) end end sum = sum + product; end print sum; end

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    this is what i tried to write,too bad it didn t work.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Of course not, you tried to paste the algorithm into a .m without regard to Matlab syntax and the picture algorithm is badly written. I can't tell if it means a do while or for loop or what types of inputs you are using (vectors, constants, etc).

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I'll get you started off, but I have no idea about you are attempting to accomplish, what test cases you have, what the inputs are or what information you have about this. You have two inputs with the same name. I recommend including better info in the future... function sum = test(x, y, n) % assuming y is a vector % assuming x is a vector sum = 0; for i = 1 : n product = y(i); for j = 1 : n if i ~= j product = product .* (x - x(j)) ./ (x(i) - x(j)) end end sum = sum + product; end return

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    It seems from the picture that there is another parameter 'X'. you should name it differently as JD pointed out. otherwise this line 'product = product .* (x - x(j)) ./ (x(i) - x(j))' won't work. Try change x into x1 and include it into the function at the first line. Good luck

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Assuming x is a vector, you are subtracting a scalar from a vector (which is fine), dividing a vector by a scalar (which is fine) and multiplying each vector element by a scalar (which is fine).

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah, but can't figure out what this function is trying to do. This is a real problem.

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hi guys,sorry for the late reply,thank you very much for your help. and here is the whole question: http://oi55.tinypic.com/20r4ryp.jpg

  9. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.