Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Given a function and x limits of a function, how do I divide y-coordinates of a function in set increments?

1 vue (au cours des 30 derniers jours)
soloby
soloby le 4 Juin 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
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

Réponses (1)

Star Strider
Star Strider le 4 Juin 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 commentaires
soloby
soloby le 4 Juin 2015
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 le 4 Juin 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.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by