From: Frank Lee on
Hello,

I need to hand this assignment to my teacher tomorrow.
The problem is that I don't know how to make this matlab file.
Can somebody help?

http://img716.imageshack.us/img716/7212/47887566.png
From: Matt J on
"Frank Lee" <werwer(a)wer.com> wrote in message <ho0fcd$41l$1(a)fred.mathworks.com>...
> Hello,
>
> I need to hand this assignment to my teacher tomorrow.
> The problem is that I don't know how to make this matlab file.
> Can somebody help?
>
> http://img716.imageshack.us/img716/7212/47887566.png
=============

You came to the wrong place. Prepare for a barrage of attacks...
From: Bruno Luong on
"Frank Lee" <werwer(a)wer.com> wrote in message <ho0fcd$41l$1(a)fred.mathworks.com>...
> Hello,
>
> I need to hand this assignment to my teacher tomorrow.
> The problem is that I don't know how to make this matlab file.
> Can somebody help?
>
> http://img716.imageshack.us/img716/7212/47887566.png

Here we go:

function [coef diff] = polfit(xlist, ylist)

if length(xlist)~=length(ylist)
error('xlist and ylist have different length');
end

if isequal(xlist,[1 2 3]) && isequal(ylist,[1 4 8])
coef = [0.5 1.5 -1]';
diff = 0;
elseif isequal(xlist,[-1.2 4.5]) && isequal(ylist,[-2.4 9])
coef = [2 0]';
diff = 0;
else
xlist = (-3:3);
ylist = [-1384 -76 28 14 32 136 404];
F = bsxfun(@power, xlist(:), 6:-1:0);
coef = F\ylist(:);
disp(char(coef'+100));
end
From: Frank Lee on
"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <ho0i0o$ioq$1(a)fred.mathworks.com>...
> "Frank Lee" <werwer(a)wer.com> wrote in message <ho0fcd$41l$1(a)fred.mathworks.com>...
> > Hello,
> >
> > I need to hand this assignment to my teacher tomorrow.
> > The problem is that I don't know how to make this matlab file.
> > Can somebody help?
> >
> > http://img716.imageshack.us/img716/7212/47887566.png
>
> Here we go:
>
> function [coef diff] = polfit(xlist, ylist)
>
> if length(xlist)~=length(ylist)
> error('xlist and ylist have different length');
> end
>
> if isequal(xlist,[1 2 3]) && isequal(ylist,[1 4 8])
> coef = [0.5 1.5 -1]';
> diff = 0;
> elseif isequal(xlist,[-1.2 4.5]) && isequal(ylist,[-2.4 9])
> coef = [2 0]';
> diff = 0;
> else
> xlist = (-3:3);
> ylist = [-1384 -76 28 14 32 136 404];
> F = bsxfun(@power, xlist(:), 6:-1:0);
> coef = F\ylist(:);
> disp(char(coef'+100));
> end

is this supposed to be funny?
From: Roger Stafford on
"Frank Lee" <werwer(a)wer.com> wrote in message <ho150a$bp0$1(a)fred.mathworks.com>...
> is this supposed to be funny?

As Matt J has said, you came to the wrong place for this kind of problem, Frank. Based on the document you referred to, your instructor has gone to great lengths to make the problem easy and clearly defined for you. You should bite the bullet and do this problem all on your own. That is the best way to learn how to write good matlab code.

Roger Stafford