?
Solved

Get x axis value at point matlab

Posted on 2010-11-17
4
Medium Priority
?
1,007 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 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