You are on page 1of 13

y

0
1
2
3

u(y)
0
55.56
88.89
100

'U(y)

''U(y)

'''U(y)

55.56
33.33
11.11

-22.23
-22.22

0.01

polynom derajad 1
120
f(x) = 33.33x + 11.11
R = 0.92

100
80

U(y)

60
40
20
0

0.5

1.5

2.5

3.5

y
Linear ()

polynom derajad 2
120
100

f(x) = - 11.11x^2 + 66.67x + 0


R = 1

80

U(y)

60
40
20
0

0.5

1.5

2.5

y
Polynomial ()

3.5

polynom derajad 3
120
100

f(x) = 0x^3 - 11.12x^2 + 66.68x + 0


R = 1

80

U(y)

60
40
20
0

0.5

1.5

2.5

y
Polynomial ()

3.5

first differential
60
50
40
30
20
10
0
0.5

1.5

2.5

3.5

second differential
5

-25

-20

-15

-10

-5

-5
-10
-15
-20
-25

function [fitresult, gof] = createFit1(x, z)


%CREATEFIT1(X,Z)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
%
X Input : x
%
Y Output: z
% Output:
%
fitresult : a fit object representing the fit.
%
gof : structure with goodness-of fit info.
%

See also FIT, CFIT, SFIT.

Auto-generated by MATLAB on 12-May-2015 21:07:07

%% Fit: 'untitled fit 1'.


[xData, yData] = prepareCurveData( x, z );
% Set up fittype and options.
ft = fittype( 'poly1' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'z vs. x', 'untitled fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel( 'x' );
ylabel( 'z' );
grid on

function [fitresult, gof] = createFit2(x, z)


%CREATEFIT2(X,Z)
% Create a fit.
%

%
%
%
%
%
%
%
%

Data for 'untitled fit 1' fit:


X Input : x
Y Output: z
Output:
fitresult : a fit object representing the fit.
gof : structure with goodness-of fit info.

Auto-generated by MATLAB on 12-May-2015 22:43:44

See also FIT, CFIT, SFIT.

%% Fit: 'untitled fit 1'.


[xData, yData] = prepareCurveData( x, z );
% Set up fittype and options.
ft = fittype( 'poly2' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'z vs. x', 'untitled fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel( 'x' );
ylabel( 'z' );
grid on

x = 0:.01:3;
y = 33.333*x + 11.113;
plot(x,y)
grid on
deriv_y = diff(y)./diff(x);
xd = x(2:length(x)-1);
figure
xd = x(2:length(x)); % Backward difference x values
plot(xd,deriv_y)
grid on

function [fitresult, gof] = createFit3(x, z)


%CREATEFIT3(X,Z)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
%
X Input : x
%
Y Output: z
% Output:
%
fitresult : a fit object representing the fit.
%
gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
%

Auto-generated by MATLAB on 12-May-2015 22:46:03

%% Fit: 'untitled fit 1'.


[xData, yData] = prepareCurveData( x, z );
% Set up fittype and options.
ft = fittype( 'poly3' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'z vs. x', 'untitled fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel( 'x' );
ylabel( 'z' );
grid on

x = 0:.01:3;
y = 33.33*x + 11.11;
plot(x,y)
grid on
deriv_y = diff(y)./diff(x);
xd = x(2:length(x)-1);
figure
xd = x(2:length(x)); % Backward difference x values
plot(xd,deriv_y)
grid on

x = 0:.1:3;
y = 0.0017*x.^3 - 11.12*x.^2 + 66.678*x - (0.000000000007);
plot(x,y)
grid on
deriv_y = diff(y)./diff(x);

xd = x(2:length(x)-1);
figure
xd = x(2:length(x)); % Backward difference x values
plot(xd,deriv_y)
grid on

x = 0:.01:3;
y = -11.113*x.^2 + 66.671*x + 0.0005;
plot(x,y)
grid on
deriv_y = diff(y)./diff(x);
xd = x(2:length(x)-1);
figure
xd = x(2:length(x)); % Backward difference x values
plot(xd,deriv_y)
grid on

You might also like