Question: Requirements: erview this exercise, you will be writing a function that finds what spring constant k is required in order to minimise the RMSE of

Requirements: erview this exercise, you will be writing a function that finds what spring constant k is required in order to minimise the RMSE of a spring stiffness test o find the spring constant k_best that minimizes RMSE, you will need to apply MATLAB's in-built function fminsearch and the function rmse(data,k) defined in Exercise You do not have to code this function yourself here. This function is provided to you and can be called as rmse(data,k) e function rmse was prepared by us as a working solution to Exercise 3. You can execute it in your code by calling it like any other Matlab in-built function. min search is a function in MATLAB that numerically solves a local minimum of a function. x = fmin search (Func, x0) will numerically approximate the x value that s the function Func (x) and uses xe as a starting point. nputs: ata - this is a matrix containing data from a spring stiffness test. Column 1 is the force data and column 2 is the displacement data. Your code should work regardless of how many data has k_guess - this is an initial guess for the spring stiffness. utputs: k best-the value for k that mini mises root mean square error between the displacement data and the displacement predicted from x = F . 1. Create an anonymous function k > rmse(data, k) that represents the RMSE of the data and fit line for any value ofk and that can be used as input to fminsearch remember the creation of anymous functions uses the"(var)" notation) Apply fminsearch to solve for the k value that minimizes RMSE. Use k_guess as the starting point for the approximation. Function Template unction k best INSERT CODE rmse min2(data,k guess) end Test Example ou can try testing your function on the data matrix and k value you were provided in Exercise 1 of Week 10 (this week) Requirements: erview this exercise, you will be writing a function that finds what spring constant k is required in order to minimise the RMSE of a spring stiffness test o find the spring constant k_best that minimizes RMSE, you will need to apply MATLAB's in-built function fminsearch and the function rmse(data,k) defined in Exercise You do not have to code this function yourself here. This function is provided to you and can be called as rmse(data,k) e function rmse was prepared by us as a working solution to Exercise 3. You can execute it in your code by calling it like any other Matlab in-built function. min search is a function in MATLAB that numerically solves a local minimum of a function. x = fmin search (Func, x0) will numerically approximate the x value that s the function Func (x) and uses xe as a starting point. nputs: ata - this is a matrix containing data from a spring stiffness test. Column 1 is the force data and column 2 is the displacement data. Your code should work regardless of how many data has k_guess - this is an initial guess for the spring stiffness. utputs: k best-the value for k that mini mises root mean square error between the displacement data and the displacement predicted from x = F . 1. Create an anonymous function k > rmse(data, k) that represents the RMSE of the data and fit line for any value ofk and that can be used as input to fminsearch remember the creation of anymous functions uses the"(var)" notation) Apply fminsearch to solve for the k value that minimizes RMSE. Use k_guess as the starting point for the approximation. Function Template unction k best INSERT CODE rmse min2(data,k guess) end Test Example ou can try testing your function on the data matrix and k value you were provided in Exercise 1 of Week 10 (this week)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
