TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Octave

Octave Input and Output

Overview

In this tutorial, we will learn about Octave input and output
statements.

Input

The input function can be used to prompt the user for a value and store the result in a variable.

For example, the statement prints the prompt and stores the user input in a variable num.

num = input (“Enter the number: “)

 

Octave Input Statement

>> a = input(‘Enter number=’);
Enter number=47
>> a
a = 47
>> disp(a)
47

Output

To print the value of a variable, we can use the disp function.
For example, the following statement will output the value of the variable num.

We can use the following output statements in Octave:

  • disp
  • printf
  • fprintf

We can use the format specifiers in the output statement, for example in the fprintf statement.

Format Specifier
Description
%d

 

To print scalar numbers.
%f

 

To print floating-point numbers.
%c To print a single character.
%s To print strings.

Example to use the display function:

disp (num)

Example to use the fprintf function:

fprintf(‘%d’,num);

 

Octave Output Statement

>> a = 25;
>> a
a = 25
>> disp(a)
25
>> fprintf(‘Value of a = %d\n’,a);
Value of a = 25

—

Octave Tutorials

Octave Tutorial on this website can be found at:
https://www.testingdocs.com/octave-tutorial/

More information on Octave can be found on the official website:
https://www.gnu.org/software/octave/index

Related Posts

Octave Package List

Octave /

Install Octave Packages on Linux

Octave /

Octave User defined Function Example

octave command line linux

Octave /

Octave Command line on Ubuntu

Hello World in Octave

Octave /

Hello World in Octave

Octave /

Octave plot example of function y=x^2

‹ Octave continue Statement› Octave Assignment Expression

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version