Question

P3.18. It is desired to fit an equation of the form f = ar ºr through some data obtained by a computer simulation. Specifical

above by minimizing the sum of square of the deviations between simulated and predicted values of f. Ssimulated 12 2.122 9.42

0 0
Add a comment Improve this question Transcribed image text
Answer #1

- t=an Tag First we have to linearize this equ to find parameter values a, and a by taking log on both ride we get log (f) a

%&MATLAB code for finding coefficients for given data clear all close all All data f=[2.122; 9.429; 23.57; 74.25; 6.286); x1=[ 1.0, 1.61, 2.3) [ 1.0, 1.1, 0] [ 1.0, -0.511, -0.511) [ 1.0, -2.3, 0.693] [ 1.0, 1.1, 0.588) b matrix is 0.752 2.24 3.16 4.

%%MATLAB code for finding coefficients for given data
clear all
close all

%All data
f=[2.122; 9.429; 23.57; 74.25; 6.286];
x1=[5;3;0.6;0.1;3];
x2=[10;1;0.6;2.0;1.8];

%log of all data
lg_f=log(f);
lg_x1=log(x1);
lg_x2=log(x2);

%in matrix form
for i=1:length(f)
    A(i,1)=1;
    A(i,2)=lg_x1(i);
    A(i,3)=lg_x2(i);
  
    b(i,1)=lg_f(i);
end
fprintf('A matrix is\n')
disp(vpa(A,3))
fprintf('b matrix is\n')
disp(vpa(b,3))

cc=A\b;
fprintf('The parameter a1=%f, c1=%f and c2=%f\n',cc(1),cc(2),cc(3))

fprintf('\n\tHence the actual parameter a=%f, c1=%f and c2=%f\n',exp(cc(1)),cc(2),cc(3))

fprintf('\tThe equation is f=(%f)*x1^(%f)*x2^(%f)\n',exp(cc(1)),cc(2),cc(3));

fun=@(x1,x2) exp(cc(1))*x1^cc(2)*x2^cc(3);

%plotting the function and model
hold on
plot(f,'r*')
for i=1:length(x1)
    ff(i)=fun(x1(i),x2(i));
end
plot(ff)
title('Plotting the function for given x1 and x2')
ylabel('f_simulated')
legend('Actual data','simulated model','location','best')
box on; grid on;
%%%%%%%%%%%%%% End of Code %%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
P3.18. It is desired to fit an equation of the form f = ar ºr through...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT