Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We are asked to use Matlab #MATLAB #Matlab Consider a ball - shape model: (x - a

ID: 3781463 • Letter: W

Question

We are asked to use Matlab #MATLAB #Matlab Consider a ball - shape model: (x - a)^2 + (y - b)^2 + (z - c)^2 = r^2 where (a, b, c) is the center and r is the radius. We can transform this model into a linear one by noting that: Write a function my Fit: output = my Fit (X), where X is an 3-by-n dataset matrix, with each column is a dataset. method: 1 for using the above transformation method, 2 for using the "fminsearch" method. output: a column vector of the derived [a, b, c, r]*. (where * indicates optimal values). J (X: a, b, c, r) = sigma^n_i = 1 (||x_i - [a, b, c]|| - r)^2, where x_i, is the itch column of the dataset matrix X. Please generate a ball dataset with r = 10, a = b = c = 1, and add zero-mean unit-variance Gaussian noise into it. Please use my Fit to derive the model parameters. Write down the derived model mathematically. Last, please visualize the resulting model along with sample points using a figure.

Explanation / Answer

rng default
%declaring limits
xdata = 0:0.1:1;
Ydata = 30*exp(-0.3*xdata) + randn(size(xdata));

function res = sseval(t,xdata,Ydata)
   P = t(1);
   lambda = t(2);
   res = sum((Ydata - P*exp(-lambda*xdata)).^2);

fun = @(t)sseval(t,xdata,Ydata);
p0 = rand(2,1);
bestx = fminsearch(fun,p0)
P = bestx(1);
lambda = bestx(2);
yfitVal = P*exp(-lambda*xdata);
plot(xdata,Ydata,'*');
hold on
plot(xdata,yfitVal,'r');
xlabel('xdata')
ylabel('Result data')
title('Best Fitting')
legend('Given data','fitted-Curve')
hold off

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote