Info
This question is closed. Reopen it to edit or answer.
Given a function and x limits of a function, how do I divide y-coordinates of a function in set increments?
1 view (last 30 days)
Show older comments
for example,
x = -20:0.4:20; f1 = gaussmf(x, [2 2]);
I am working on fuzzy operations so I need to get the lower and upper bounds of x for incremental values of y, for example, if my y is 0 to 1 i need each x-values of y from 0, 0.01, 0.02.. ..0.99, 1
what's the best way to get the x-values? find() doesn't work because matlab already assigns f1 101 values that's not in increments of 0.01
0 Comments
Answers (1)
Star Strider
on 4 Jun 2015
It depends on the nature of your function. You could use a generic regression function such as polyfit or an interpolation function such as interp1, with the x and y arguments reversed from the usual order, since you want the x values for certain values of y.
4 Comments
Star Strider
on 4 Jun 2015
My pleasure.
To apply it to gaussmf(x,[2 2]) directly, you would have to calculate its inverse. The easiest way to do that is with the fzero function. You would have to do that in a loop, but you would only have to do it for values of x<=2, and create a symmetric vector with values for x>2.
To calculate the x for a particular y, try this:
sig = 2;
c = 2;
invgaussmf = @(x,y) gaussmf(x, [sig c])-y; % Inverse Function
N = 10;
y = linspace(1E-4, 1-1E-4, N); % Vector Of ‘y’
for k1 = 1:N
x = fzero(@(x) invgaussmf(x,y(k1)), 0.5);
mf(k1,:) = [y(k1) x]; % [y x] Matrix
end
You will probably have to experiment with it to get the result you want. You might want to plot y as a function of x to be sure it’s doing what you want.
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!