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

답변 (1개)

Star Strider
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
soloby
soloby 2015년 6월 4일
this looks very promising, I just have a couple of questions, is there a way i can apply this to the gaussmf(x, [2 2]) function directly? and why did you choose alpha to be .95? I assume it's arbitrary.
thanks very much for your help
Star Strider
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!

Translated by