Matlab Code For Power Consumption
Matlab Code For Power Consumption
>> x = 1:5
x=
1 2 3 4 5
y=
>> n = length(x)
n= 5
>> D = zeros(n,n)
D=
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
>> D(:,1)= y
D=
620 0 0 0 0
600 0 0 0 0
610 0 0 0 0
600 0 0 0 0
860 0 0 0 0
for i= j:n
end
end
for i=j:n
D(i,j)= (D(i,j-1)- D(i-1,j-1))/(x(i)-x(i-j+1));
end
end
>> D
D=
620.0000 0 0 0 0
600.0000 -20.0000 0 0 0
>> A = D(n,n);
A = conv(A,poly(x(k)));
r = length(A);
end
>> A
A=
1.0e+03 *
>> polyval(A,1.5)
ans = 589.8438
>> polyval(A,2.5)
ans = 612.3438
>> polyval(A,3.5)
ans = 597.3438
>> polyval(A,4.5)
ans = 664.8438