anonymous
  • anonymous
Can anyone please help me to write this matlab m-file? Here is the pseudocode : http://oi53.tinypic.com/u1pvc.jpg
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
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
anonymous
  • anonymous
this is what i tried to write,too bad it didn t work.
anonymous
  • anonymous
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).

Looking for something else?

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

More answers

anonymous
  • anonymous
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
anonymous
  • anonymous
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
anonymous
  • anonymous
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).
anonymous
  • anonymous
yeah, but can't figure out what this function is trying to do. This is a real problem.
anonymous
  • anonymous
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

Looking for something else?

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