Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Given a function and x limits of a function, how do I divide y-coordinates of a function in set increments?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Star Strider
am 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 Kommentare
Star Strider
am 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.
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!