Using strcmpi with if / else
The function strcmpi compares two strings ignoring case and returns a logical value. Thus, you need to use it as follows:
dist = 'markovian';
x = pi/7;
if strcmpi(dist, 'lorentzian')
z = sin(x)
elseif strcmpi(dist, 'markovian')
z = cos(x)
else
z = sin(x) + cos(x)
end
Using switch
The code may be clearer with a switch statement. You can use lower to achieve case insensitivity.
dist = 'markovian';
x = pi/7;
switch lower(dist)
case 'lorentzian'
z = sin(x)
case 'markovian'
z = cos(x)
otherwise
z = sin(x) + cos(x)
end
Without branching
Here is an alternative that avoids branching. If you only have two or three options this approach is unnecesarily complicated, but if there are many options it may be more adequate for compactness or even readability.
This works by finding the index of the chosen option in a cell array of char vectors, if present; and using feval to evaluate the corresponding function from a cell array of function handles:
names = {'lorentzian', 'markovian'}; % names: cell array of char vectors
funs = {@(x)sin(x), @(x)cos(x), @(x)sin(x)+cos(x)}; % functions: cell array of handles.
% Note there is one more than names
dist = 'markovian';
x = pi/7;
[~, ind] = ismember(lower(dist), names); % index of dist in names
ind = ind + (ind==0)*numel(funs); % if 0 (dist not in names), select last function
feval(funs{ind}, x)