Solved

Get x axis value at point matlab

Posted on 2010-11-17
4
964 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Virtuailstring tree add node to another virtuailstring tree list 4 104
notReplace  challenge 53 116
string initialization in java 11 109
base64 decode encode 12 119
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

919 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

18 Experts available now in Live!

Get 1:1 Help Now