Info
此问题已关闭。 请重新打开它进行编辑或回答。
Given a function and x limits of a function, how do I divide y-coordinates of a function in set increments?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Star Strider
2015-6-4
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 个评论
Star Strider
2015-6-4
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.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!