Same plot for two functions

View: New views
3 Messages — Rating Filter:   Alert me  

Same plot for two functions

by george brida :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear friends,
if I have two functions of variable t, how to represent them in the same plot?
Say, f(t)=2*t and g(t)=t*t
Thank you very much

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

Re: Same plot for two functions

by Henry F. Mollet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

octave-3.0.1:2> t=linspace(0,10,21);
octave-3.0.1:3> plot (t, 2.*t, t, t.*t)
Henry


on 5/13/08 3:35 PM, george brida at george.brida@... wrote:

> Dear friends,
> if I have two functions of variable t, how to represent them in the same
> plot?
> Say, f(t)=2*t and g(t)=t*t
> Thank you very much
> _______________________________________________
> Help-octave mailing list
> Help-octave@...
> https://www.cae.wisc.edu/mailman/listinfo/help-octave


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

Re: Same plot for two functions

by Thomas G.-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello George,
another option is the command
 hold on/off

A little example using some more options:
% Create "time"-vector
t = [1:1/10:2*pi];
% Open figure number 1
figure(1)
% Clear the figure
clf
% Plot a sine-wave
% -  --> full line
% r --> color is red
% d --> marker diamond
plot(t,sin(t),'-rd')

% Tell octave to hold the plot
hold on

% Plot cosine with double frequency
% . --> print only points
%o --> marker circle
% b --> line is blue
plot(t,cos(2*t),'.ob')

% Switch on the grid
grid on

% Give some description
xlabel('Time / s')
ylabel(' \phi / -')
title('This is an example')

Regard
Thomas


george brida schrieb:
Dear friends,
if I have two functions of variable t, how to represent them in the same plot?
Say, f(t)=2*t and g(t)=t*t
Thank you very much

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


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