Sumera Yamin
Sumera Yamin

Reputation: 1

Fitting a curve to find argument of transfer function

I have a pair of data vectors, x and y, defined as follows:

data = [
     0    0; 
     0.05 1.108646244630E-01;
     0.10 2.217423074817E-01;
     0.15 3.325947375398E-01;
     0.20 4.434863433851E-01;
     0.25 5.543595496420E-01;
     0.30 6.652338361973E-01;
     0.35 7.761094191116E-01;
     0.40 8.869865144820E-01;
     0.45 9.978653384221E-01;
     0.50 1.108746107036E+00];

 x = data(:,1);
 y = data(:,2);

they are related by the equation

y = (cos(k*L)^2-(0.8194*k*cos(k*L)*sin(k*L))*x;

where k=3 is a fixed number.

Now I want to find the right value of L for which the above equation fits my data.

Although the data appears linear, I want to find the right value of L for which data fits the initial linear part of sinusoidal curve of this transfer function.

How do I solve this kind of problem?

Upvotes: 0

Views: 337

Answers (1)

Dev-iL
Dev-iL

Reputation: 24169

Here's how to do it using the curve fitting toolbox:

  1. Start by defining x and y, then calling cftool:

    Command window screenshot

  2. You will get the following screen, where you need to choose your "X data" and your "Y data":

    cftool start screen screenshot

  3. After choosing the x and y vectors we created before, a default linear fit will be shown:

    cftool default fit screenshot

    (as you can already see, this is a practically an ideal fit for the relation between x and y)

  4. To make cftool fit your desired model, click the dropdown box that says "Polynomial" and choose the option "Custom Equation", then write your model. If the Auto fit checkbox is selected (it is by default), you will get a fit right away:

    enter image description here

As you can see, we got that L = 0.7157, but we also see that the fit doesn't really go through the points, which means that at least one of the following statements is true:

  • The model (i.e. the custom equation in which L appears) is incorrect.
  • The fitting problem is set up incorrectly (e.g. the found L is outside of the expected bounds etc.).

It is up to you to find the root of the problem (could be misplaced parentheses in the model) and fix it.

Upvotes: 1

Related Questions