Open In App

Void Function in MATLAB

Improve
Improve
Like Article
Like
Save
Share
Report

When defining void* output in the library definition file, MATLAB specifies that the argument MLTYPE must be one of these: a typedef from the library. Use only to produce scalar data. If the library has a typedef defined for void* that uses that name, MATLAB specifies MLTYPE as the new type name in the typedef statement. The two defined arrays will be the function’s output, and its input parameters will be void. When used as a function return type, the void keyword indicates that a function does not return a value. When the word void appears in the parameter list, it means that a function accepts no arguments. void functions are created and used just like value-returning functions, with the exception that they do not return a value after the function has been completed. void functions substitute the keyword “void” for a data type. A void function does something and then gives control back to the caller, but it doesn’t return a value.

Syntax:

input parameters = function name; output parameters

% Declarations

end

  • Output parameters define the function’s returning variables
  • function name specifies the function’s name.
  • The function’s input arguments are called input parameters.

Here are a few MATLAB examples showing how to use functions:

Example 1:

Matlab




% MATLAB code for Void function
function[]=drives(driver,drive)
  
% DRIVES Adds drives between the name of drive and driver
% Detailed explanation goes here
  
string1= [driver,'drives',drive];
disp(string1)
end


Output:

 

Example 2:

Matlab




% MATLAB code for Void function
function[]=plays(cricketer,game)
  
% PLAYS Adds PLAYS between the name of game and cricketer
% Detailed explanation goes here
  
string1= [game,'plays',play];
disp(string1)
end


Output:

 


Last Updated : 22 Nov, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads