MATLAB function trouble using (wtls_line)

In summary: Your Name]In summary, a new user named Michael is seeking help with using MATLAB to analyze neutron count data. They are attempting to use the wtls_line function, but are receiving an error message. It is suggested that the function may not be properly added to the MATLAB path and that the input data must be in the correct format. Other built-in functions for linear regression are also mentioned. Ultimately, Michael figures out the issue and apologizes for the mistake.
  • #1
NeoGenus59
1
0
Hello,

I'm new here and I'm trying to figure out how to use MATLAB to crunch some numbers about neutron counts. I have data from a detctor and ultimately I'd like to linearize it!

I'm using wtls_line found at: http://www.mathworks.com/matlabcentral/fileexchange/17466-weighted-total-least-squares-straight-line-fit/content/wtls_line.m

OK so when I go to extract the data--attached, I use a column, from a file of type .m, which is a double (and I believe is the cause of the problem).

Upon trying to use wtls_line, I define xin, yin, uxin, yxin, and guck, (all are necessary to work properly, correct?) Then I type:

[a,b,alpha,p,chiopt,Cab,Calphap]= wtls_line(xin,yin,uxin,uyin,guck)

which returns

Undefined function 'wtls_line' for input arguments of type 'double'.

It may be that I don't know how to properly call upon a function but I think I either need to change the data I'm extracting from double to something else or the problem is something that I don't know. Does anyone have any clue how to solve this issue?

Also, I plan on plotting this information against the same data type (neutron counts) but for other detectors... (may be irrelevant)

I appreciate any help you can offer! Thank you.

-Michael

Figured it out: the file name didn't match the function name. I did a 'save as...' and changed the name. Sorry.
 

Attachments

  • trig_counts2_2.txt
    947 bytes · Views: 423
Last edited:
Physics news on Phys.org
  • #2


Hi Michael,

Welcome to the forum! It sounds like you are on the right track with using the wtls_line function for your neutron count data analysis. The error message you are receiving is likely due to the function not being properly added to your MATLAB path. To do this, you can either add the folder containing the wtls_line function to your path using the "addpath" command, or you can use the full file path when calling the function (e.g. [a,b,alpha,p,chiopt,Cab,Calphap]= wtls_line('C:\Users\username\Documents\wtls_line.m', xin, yin, uxin, uyin, guck)).

As for the data types, it is important to make sure that your input data (xin, yin, uxin, uyin, guck) are all in the correct format for the function. For example, xin and yin should be vectors of the same length, and uxin and uyin should be the corresponding uncertainties for each data point. It is also important to note that the function assumes the data follows a linear relationship, so if your data does not fit this assumption, the results may not be accurate.

I also wanted to mention that there are other built-in functions in MATLAB that can perform linear regression, such as "polyfit" and "regress". These may be worth looking into as well.

Best of luck with your analysis and let us know if you have any further questions.
 

Related to MATLAB function trouble using (wtls_line)

What is the purpose of the "wtls_line" function in MATLAB?

The "wtls_line" function in MATLAB is used to perform a weighted total least squares regression on a set of data points. It is often used in situations where there is uncertainty or error in both the independent and dependent variables.

Why might I be experiencing trouble using the "wtls_line" function?

There could be several reasons for trouble using the "wtls_line" function. Some common issues include incorrect input arguments, data points with zero weights, or data that does not follow a linear trend. It is important to carefully check the input parameters and data to ensure they are appropriate for the function.

What is the syntax for using the "wtls_line" function?

The syntax for the "wtls_line" function is: [m,b,r,sm,sb] = wtls_line(x,y,w,intercept). The inputs x, y, and w represent the independent variable, dependent variable, and weights, respectively. The intercept input is optional and defaults to 0 if not specified. The outputs m, b, r, sm, and sb represent the slope, intercept, correlation coefficient, and standard errors for the slope and intercept, respectively.

Can the "wtls_line" function handle missing or invalid data?

Yes, the "wtls_line" function can handle missing or invalid data. It uses a weighted total least squares method, which takes into account the uncertainty in both the independent and dependent variables. However, it is still important to carefully check the data and input parameters to ensure they are appropriate for the function.

Is there a specific data format required for the "wtls_line" function?

No, there is no specific data format required for the "wtls_line" function. It can handle both row and column vectors for the independent and dependent variables, as well as different data types such as numeric or symbolic. However, the data must be in a matrix format, with each data point represented by a row or column.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top