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」で使われたファイルです

createSurfaceFit(thisHour, thisTemp, thisPower)
function [fitresult, gof] = createSurfaceFit(thisHour, thisTemp, thisPower)
%CREATESURFACEFIT1(THISHOUR,THISTEMP,THISPOWER)
%  Fit surface to data.
%
%  Data for 'untitled fit 1' fit:
%      X Input : thisHour
%      Y Input : thisTemp
%      Z output: thisPower
%      Weights : (none)
%
%  Output:
%      fitresult : an sfit object representing the fit.
%      gof : structure with goodness-of fit info.
%
%  See also FIT, SFIT.

%  Auto-generated by MATLAB on 23-Jun-2009 16:54:30


%% Fit: 'untitled fit 1'.
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);
[fitresult, gof] = fit( [thisHour, thisTemp], thisPower, ft, opts );

% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, [thisHour, thisTemp], thisPower );
grid on
% Label axes
xlabel( 'thisHour' );
ylabel( 'thisTemp' );
zlabel( 'thisPower' );
legend( h, 'untitled fit 1', 'thisPower vs. thisHour, thisTemp', 'Location', 'NorthEast' );
view( -58.5, 22 );axis vis3d;
set(gcf,'renderer','opengl')

Contact us