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 User defined Function Example

Introduction

In this tutorial, we will learn about user-defined functions in Octave. User-defined functions are stored in a separate file with the filename as the function name.

User-defined function

Let’s write a sample function to convert Fahrenheit temperature to Celsius temperature.

We will use the following conversion formula:

 

 

 function [Celsius] = FahToCel(Fahrenheit)
% Function: FahToCel.m
% 
Celsius = 5*(Fahrenheit-32)/9;
endfunction

Function Call

We can invoke the function with the function name and pass the parameters.

%Sample Usage
% How to invoke the user defined function
celsius = FahToCel(50);
disp(celsius);

 

—

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 /

Install Octave Packages on Linux

Octave /

Octave Command line on Ubuntu

Octave /

Hello World in Octave

Octave /

Octave plot example of function y=x^2

Octave /

Install Octave on Ubuntu Linux

‹ Octave Command line on Ubuntu› Install Octave Packages on Linux

Recent Posts

  • Scaler Academy – An Online Learning Platform
  • Difference between PHP and JavaScript?
  • 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

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com