Can anyone please help me to write this matlab m-file?
Here is the pseudocode :
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
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.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
sum = 0 ;
while i = 0,n
product = yi;
while j = 0,n
if a ~= b
product = product * ( x - xj ) / (xi - xj)
sum = sum + product;
this is what i tried to write,too bad it didn t work.
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).
Not the answer you are looking for? Search for more explanations.
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))
sum = sum + product;
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.
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).
yeah, but can't figure out what this function is trying to do.
This is a real problem.
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