help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plot the function error


From: Stefan Neumann
Subject: Re: Plot the function error
Date: Fri, 26 Mar 2010 23:56:02 +0100



2010/3/26 Abdul Rahman Riza <address@hidden>
Thank you Stefan,

That exactly what I wanted.

I am wondering if octave able to plot 2 function f(x) and g(x) simultaneously where 0 < x < 26



Part of it:

define f(x) , f'(x) , f''(x) , solve f'(x)=0, display solution , plot everything in one graph:

x=0:.1:26;
function y=f(x) y=1./((206./x)+1.7*x+5.2); endfunction
function dx=dx(x) dx=(f(x+1e-5)-f(x))/1e-5; endfunction % differentiate to find maximum
function d2x=d2x(x) d2x=(dx(x+1e-5)-dx(x))/1e-5; endfunction % differentiate again for check if max or min
xaxis=zeros(1,length(x));                % hack inexpertly :-)  : line at y=0
xmax = fsolve('dx',1) ;    % find extremes
xmax     % display solution
plot( x,xaxis ,  xmax*ones(1,2),[-.0095,.025],';xmax;'  ,  x,f(x),';f(x);'  ,  x,5*dx(x),';dx(x);'  ,   x,10*d2x(x),';d2x(x);' );    % plot them all


Kind of fun, actually :-D

cheers, Stefan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]