Question: I need help fixing my MATLAB code, I got a 1 / 2 . Here are the instructions: General curve fitting with nlinfit Assume these
I need help fixing my MATLAB code, I got a Here are the instructions:
General curve fitting with nlinfit
Assume these variables are already defined:
list list of values
Ylist list of y values
single value
Write a MATLAB code segment that uses nlinfit to determine the best fit curve for the points in Xlist and Ylist according to this equation
where and are constants. Use initial guesses of and
Your results should be stored in a structure named fitData with the following fields:
A : determined coefficient A
: determined coeeficient
: determined coefficient
: provided value of
: value of your curve fit equation evaluated at
Example Test Case:
clear all; clc; format compact; format short g;
Xlist ;
Ylist ;
;
your code for the submit to MATLAB box here
fitData
Should display this result in the command window
fitData
:
:
:
:
:
Your code should work for any set of starting values. Do not include test cases, clear all, etc as part of your submission.
My Code:
clear all; clc; format compact; format short g;
Xlist ;
Ylist ;
X ;
fitData struct;
y @bxb bmaxx eps expbx;
InitialCoff ; A B C
NewCoff nlinfitXlist, Ylist, y InitialCoff;
Ynew yNewCoff, X;
fitData.X X;
fitData.Y Ynew;
fitData.A NewCoff;
fitData.B NewCoff;
fitData.C NewCoff;
fitData
Result:
MATLAB results:
Start of test case
C
fitData
struct with fields:
X:
Y:
A:
B:
C:
checking answer
GOOD
End of test case
Start of test case
C
fitData
struct with fields:
X:
Y:
A:
B:
C:
checking answer
Output does not match
End of test case
of test cases corrects
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
