Please help

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Please help

Ndonifha
How do I plot this two graphs x=e^0,6667t-1.5 and y_i+1=cos(t^2).I have to find the point of intersection of this two graphs
Sent from my BlackBerry® wireless device
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Please help

Jordi Gutiérrez Hermoso-2
On 28 August 2011 12:49,  <[hidden email]> wrote:
> How do I plot this two graphs x=e^0,6667t-1.5 and y_i+1=cos(t^2).

I hope you understand that Octave is not a symbolic calculator, which
you seem to be expecting. To plot in Octave, you actually have to
define all of the points in your plot and then pass all of those
points to the plot command. In particular, you have to specify the
range to plot. The following seems reasonable:

    ## Define 100 points from -2 to 2
    t = linspace(-2, 2, 100);

    ## Define the points for x(t)
    x = exp(0.6667*t) - 1.5;

    ## Define the point for y_i(t)
    y_i = cos(t.^2);

    ## Plot them together
    plot(t,x, t,y)

> I have to find the point of intersection of this two graphs

The easiest way is probably with fsolve:

    ## Define the two functions
    f = @(t) exp(0.6667*t) - 1.5
    g = @(t) cos(t.^2)

    ## Define the function for fsolve
    h = @(t) f(t) - g(t)

    ## Use fsolve to find the zeros of h, with initial guess obtained
    ## from looking at the plot above
    t0 = fsolve(h, 1)

> Sent from my BlackBerry® wireless device
Sent from my Emacs☮ texteditorial device.

HTH,
- Jordi G. H.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave