Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
GNU Octave Beginner's Guide

You're reading from   GNU Octave Beginner's Guide Become a proficient Octave user by learning this high-level scientific numerical tool from the ground up

Arrow left icon
Product type Paperback
Published in Jun 2011
Publisher Packt
ISBN-13 9781849513326
Length 280 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jesper Schmidt Hansen Jesper Schmidt Hansen
Author Profile Icon Jesper Schmidt Hansen
Jesper Schmidt Hansen
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

GNU Octave
Credits
About the Author
About the Reviewers
1. www.PacktPub.com
2. Preface
1. Introducing GNU Octave FREE CHAPTER 2. Interacting with Octave: Variables and Operators 3. Working with Octave: Functions and Plotting 4. Rationalizing: Octave Scripts 5. Extensions: Write Your Own Octave Functions 6. Making Your Own Package: A Poisson Equation Solver 7. More Examples: Data Analysis 8. Need for Speed: Optimization and Dynamically Linked Functions Pop quiz - Answers

Time for action - having multiple graphs in the same figure


  1. 1. We start by defining the domain and the coefficients representing the polynomial:

octave:83> x = [-5.5:0.1:2]; c_1 = [2 10.1 0 6];
c_2 = [2 10.1 -10.1 6];
  1. 2. We then calculate the ranges of f1 and f2:

octave:84> f_1 = polyval(c_1, x); f_2=polyval(c_2, x);
  1. 3. And plot the graphs:

octave:85> plot(x, f_1, "linewidth", 5, x, f_2,
"linewidth", 5, "color", "red")
  • After setting the axes limits, font sizes, and so forth, the figure window looks like the next figure below.

What just happened?

From Command 85, we see that plot can plot many graphs in a single call, and that you can even specify the properties and values of each graph.

Alternatively, you can use the command hold on to force Octave to not delete the existing graph(s); that is, instead of Command 85, you can use:

octave:86> plot(x, f_1, "linewidth", 5);
octave:87> hold on
octave:88> plot(x, f_2, "linewidth", 5, "color", "red")

When you want Octave to stop "holding...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime