Clear Filters
Clear Filters

spherical variogram model function help

3 views (last 30 days)
B on 25 Feb 2017
Answered: Vandana Rajan on 28 Feb 2017
The variable ‘vdata’ that i loaded from my m file has two columns,the first is x and the second is y.I'm supposed to Use the nonlinear least-square tool ‘lsqcurvefit’ to estimate the two parameters ‘a’ and ‘c’, and fit a function of the form: y = c[1.5(x/a) - 0.5(x/a)^3] if x < a and y = c if x >= a
The optimum values for ‘a’ and ‘c’ are around 10 and 0.8 respectively. This is a vector minimization problem, so the initial values will be a 2-element vector.
My issue: I am supposed to write a function m-file to generate the spherical variogram using the equations above. in this prolem, y is sometimes a vector, and sometimes a scalar depending on the size of ‘a’—i have no idea how to even begin writing this. I am unsure what the variables a and c represent. any help would be appreciated on how to start writing this function

Answers (1)

Vandana Rajan
Vandana Rajan on 28 Feb 2017
You may check the size and type of variables inside your code, before deciding on what action to perform.
Functions like ' isscalar ' and ' isvector ' can be used to find if a variable is a scalar or a vector. To find the type of a variable, you can use ' class ' function. Also, ' cell arrays ' can be used to store elements of varying size and type. Now, if you wish to pass varying number of input arguments to a function and output varying number of arguments from a function, you can use ' varargin ' and ' varargout ' respectively.


Find more on Weather and Atmospheric Science in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!