Effacer les filtres
Effacer les filtres

find value corresponding X value to a particular Y value

4 vues (au cours des 30 derniers jours)
sri satya ravi
sri satya ravi le 11 Sep 2016
Commenté : sri satya ravi le 12 Sep 2016
a = 5;
n = 1:4;
theta_teta = -10;
delta_theta = 40;
theta = -10:1:30;
for j = 1: length (n);
for i = 1:length(theta)
f(i) = 1-exp(-a*((theta(i)-theta_teta)/delta_theta)^n(j));
end
plot (theta,f)
max_f = sum(f)
hold on
end
Hi;
I have a plot which is shown in the image above. I want to find the x value corresponding to 0.5 and 0.9 of the maximum y values for the lines i.e. at 0.5 and 0.9 what is the respective x values for the different lines.

Réponse acceptée

Image Analyst
Image Analyst le 12 Sep 2016
Would interp1 be accurate enough for you? If so, try this:
a = 5;
n = 1:4;
theta_teta = -10;
delta_theta = 40;
theta = -10:1:30;
for j = 1: length (n);
for i = 1:length(theta)
f(i) = 1-exp(-a*((theta(i)-theta_teta)/delta_theta)^n(j));
end
plot (theta, f, 'LineWidth', 2);
max_f = sum(f);
fprintf('For n = %d, the sum of f (for some reason called max_f) = %f.\n', j, max_f);
grid on;
hold on;
% Find x value for y = 0.5
x50(j) = interp1(f, theta, 0.5);
line([x50(j), x50(j)], [0, 0.5], 'LineWidth', 2, 'Color', 'k');
fprintf('For n = %d, y = 0.5 at x = %f.\n', j, x50(j));
% Find x value for y = 0.9
x90(j) = interp1(f, theta, 0.9);
line([x90(j), x90(j)], [0, 0.9], 'LineWidth', 2, 'Color', 'k');
fprintf('For n = %d, y = 0.9 at x = %f.\n', j, x90(j));
end
legend('n=1', 'n=2', 'n=3', 'n=4', 'Location', 'east');
% Put lines across at y = 0.9 and 0.5
line(xlim, [0.5, 0.5], 'LineWidth', 2, 'Color', 'k');
line(xlim, [0.9, 0.9], 'LineWidth', 2, 'Color', 'k');
% Label the axes
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
For n = 1, the sum of f (for some reason called max_f) = 32.540191.
For n = 1, y = 0.5 at x = -4.439359.
For n = 1, y = 0.9 at x = 8.435958.
For n = 2, the sum of f (for some reason called max_f) = 24.668279.
For n = 2, y = 0.5 at x = 4.894287.
For n = 2, y = 0.9 at x = 17.153014.
For n = 3, the sum of f (for some reason called max_f) = 19.624252.
For n = 3, y = 0.5 at x = 10.702175.
For n = 3, y = 0.9 at x = 20.896785.
For n = 4, the sum of f (for some reason called max_f) = 16.262926.
For n = 4, y = 0.5 at x = 14.406551.
For n = 4, y = 0.9 at x = 22.955276.
  1 commentaire
sri satya ravi
sri satya ravi le 12 Sep 2016
Hi, Thanks for your help. That works for me for this problem.
If i have an image something like this I want to know the 0.98th value of max power. That occurs on either side of the curve. How can I get the intercepts for 2 close numbers.
max_power = 523.6947

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by