Thread Subject: Getting values of y when x=0 from a plot

Subject: Getting values of y when x=0 from a plot

From: Karthik Mani

Date: 13 Nov, 2009 13:07:02

Message: 1 of 5

I have plotted (x,y) where x=f(y,z), z=1:10 in the same graph using the hold on command. I have 10 curves meeting the y axis. Now, I want to get these 10 different values of y at x=0. Is there any command to get these values of y which i need for my further calculations???

Please help.

Subject: Getting values of y when x=0 from a plot

From: Lars

Date: 13 Nov, 2009 14:03:19

Message: 2 of 5

be
>> x = -5:1:5;

and

>> y = -5:1:5;

then you can perform

>> x_ind = find(x==0);
>> y_ind = find(y==0);

can't you simply do something like

>> val = z(x_ind, y_ind);

?

Subject: Getting values of y when x=0 from a plot

From: Jos

Date: 13 Nov, 2009 14:44:02

Message: 3 of 5

"Karthik Mani" <karthmani@gmail.com> wrote in message <hdjllm$ma4$1@fred.mathworks.com>...
> I have plotted (x,y) where x=f(y,z), z=1:10 in the same graph using the hold on command. I have 10 curves meeting the y axis. Now, I want to get these 10 different values of y at x=0. Is there any command to get these values of y which i need for my further calculations???
>
> Please help.

You do not really need a plot for this, although it does give you some visual inspection.
Take a look at INTERP1

Here is an example:
% some arbitray data
x = -2*pi:0.2:2*pi ;
y = exp(x/10) .* sin(2*x+0.3) ;

any(x==0) % note that 0 is not present in x
y0 = interp1(x,y,0)
% a visual inspection
plot(x,y,'b.-', ...
  [0 0 NaN -7 7],[-2 2 NaN y0 y0],'k-', ...
  0,y0,'r+')

hth
Jos

Subject: Getting values of y when x=0 from a plot

From: Karthik Mani

Date: 13 Nov, 2009 14:50:03

Message: 4 of 5

Thank you for ur reply... But my functions x and y are a bit complicated... so this dint work... when i use x_ind=find(x==0) i get only an empty matrix...

my full program is some what like this...

x=log(y+c) + y*z; % where c are constants and y=0:.005:.04. and z = 0:10;
plot(x,y)
hold on

i get the plot of x,y for z=0:10.

these curves are meeting the y axis at different points.

How can i find the 10 y-points at x=0;

Subject: Getting values of y when x=0 from a plot

From: Karthik Mani

Date: 13 Nov, 2009 16:55:21

Message: 5 of 5

"Jos " <#10584@fileexchange.com> wrote in message <hdjrbi$elt$1@fred.mathworks.com>...
> "Karthik Mani" <karthmani@gmail.com> wrote in message <hdjllm$ma4$1@fred.mathworks.com>...
> > I have plotted (x,y) where x=f(y,z), z=1:10 in the same graph using the hold on command. I have 10 curves meeting the y axis. Now, I want to get these 10 different values of y at x=0. Is there any command to get these values of y which i need for my further calculations???
> >
> > Please help.
>
> You do not really need a plot for this, although it does give you some visual inspection.
> Take a look at INTERP1
>
> Here is an example:
> % some arbitray data
> x = -2*pi:0.2:2*pi ;
> y = exp(x/10) .* sin(2*x+0.3) ;
>
> any(x==0) % note that 0 is not present in x
> y0 = interp1(x,y,0)
> % a visual inspection
> plot(x,y,'b.-', ...
> [0 0 NaN -7 7],[-2 2 NaN y0 y0],'k-', ...
> 0,y0,'r+')
>
> hth
> Jos

Thanks a lot Jos.. Interp1 command work for me...

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
graphics Karthik Mani 13 Nov, 2009 08:44:55
plots Karthik Mani 13 Nov, 2009 08:44:55
rssFeed for this Thread

Contact us at files@mathworks.com