Code covered by the BSD License  

Highlights from
Files used in "Matlab For Excel Users" (Japanese version) / 「ExcelユーザのためのMATLAB」Webセミナーのファイル

Files used in "Matlab For Excel Users" (Japanese version) / 「ExcelユーザのためのMATLAB」Webセミナーのファイル

by

 

Webinar files: "MATLAB for Excel Users" (Japanese) Webセミナー「ExcelユーザのためのMATLAB」で使われたファイルです

energyModel(thisHour, thisTemp, thisPower, H, T)
function P = energyModel(thisHour, thisTemp, thisPower, H, T)
% ENERGYMODEL Fits a surface to given data, and predicts power usage.
%
% * |thisHour|: Hour data
% * |thisTemp|: Temperature data
% * |thisPower|: Power data
% * |H|: Hour to predict
% * |T|: Temperature to predict

% Fit surface to provided data
ft = fittype( 'a0 + a1*cos(w*x) + b1*sin(w*x) + a2*cos(2*w*x) + b2*sin(2*w*x) + c1*y^2 + c2*y', 'indep', {'x', 'y'}, 'depend', 'z' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [-Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf];
opts.StartPoint = [0.3942 0.2456 0.9898 0.8125 0.8125 0.9459 0.1852 0.5084];
opts.Upper = [Inf Inf Inf Inf Inf Inf Inf Inf];
opts.Weights = zeros(1,0);
model = fit( [thisHour, thisTemp], thisPower, ft, opts );

P = model(H,T);


Contact us