Solved

Get x axis value at point matlab

Posted on 2010-11-17
4
961 Views
Last Modified: 2016-03-02
Hello all,
I am trying to plot a circle at the min point of a plot. I am able to find the Y min value, however, I am trying to find the value of the X-axis at this point.

Thank you
clear all;
R=1600;
L=120e-6;
C=100e-9;

num = [R*L*C 0 R];
den = [R*L*C L R];

subplot(2,1,1)

system=tf(num,den);
[mag,phase]=bode(system,{2.8e5,3e5});

mag=db(mag);
[minvalue,minIndex]=min(mag);


hold on;
bodemag(system,{2.8e5,3e5});
title('Bode plot for question 1');
plot(??,minvalue,'mo');

subplot(2,1,2);
h=bodeplot(system,{2.8e5,3e5});
setoptions(h,'MagVisible','off');
title('');
hold off;

Open in new window

0
Comment
Question by:dwb178
  • 3
4 Comments
 
LVL 15

Accepted Solution

by:
yuk99 earned 500 total points
ID: 34161314
Use second output argument of MIN function to get index of the point at minimum:

[ymin, idx] = min(y);
xmin = x(idx);
0
 
LVL 1

Author Comment

by:dwb178
ID: 34161458
Hello yuk99,
Thanks for the reply. I tried that and keep getting error message:

??? Undefined function or method 'x' for input arguments of type 'double'.
0
 
LVL 15

Expert Comment

by:yuk99
ID: 34161544
How do you create the plot? What is x and y variables. In my example I used variable x as x coordinates and y as y coordinates. If you use different variables, use yours instead. Show your code to draw plot if you still have problems.
0
 
LVL 15

Expert Comment

by:yuk99
ID: 34327984
Sorry, I read the question on my smartphone and didn't see the code. So my accepted answer doesn't actually answer the question.

Here is another answer that should work in case you don't know x and y of your plot, but want to show minimum point on the plot::

hold on

bodemag(system,{2.8e5,3e5});

h = findobj(gca,'type','line');

for ii=1:numel(h);

    x = get(h(ii),'XData');

    if numel(x)==0 || any(isnan(x))

        continue

    end

    y = get(h(ii),'YData');

    break

end

[minValue,minIndex]=min(y);



plot(x(minIndex),minValue,'mo');

hold off

Open in new window

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
notReplace  challenge 53 102
countEvens challenge 2 59
Problem to event 3 52
C# code editing and collaboration 3 49
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now