Open In App

Void Function in MATLAB

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



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

Example 1:




% 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 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:

 

Article Tags :