help-octave
[Top][All Lists]
Advanced

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

Re: Plot the function error


From: Abdul Rahman Riza
Subject: Re: Plot the function error
Date: Sat, 27 Mar 2010 18:56:02 +0800

Thanks again Stefan,

I plot them together including the second part g(x) and dg(x) (to obtain xmax for g(x) in one graph

you solved xmax for f(x) (let say X1) and I continue solved xmax for g(x) (let say X2)

There's some problem remain:
1) How to hatch region of x where X1< x < X2 in gnuplot?
2) How to print the graph?

Thank you very much in advance
Riza

On Fri, 2010-03-26 at 23:56 +0100, Stefan Neumann wrote:


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


_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

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