Subroutine functions in MatLab

29 次查看(过去 30 天)
Mohamed Agha
Mohamed Agha 2018-8-9
How can I make a subroutine module (similar to another programming languages) in a MatLab m-file program?
How to call it in case you no variables between the function brackets such as "function [ init ] = init( )"?

回答(1 个)

James Tursa
James Tursa 2018-8-9
编辑:James Tursa 2018-8-9
Create a file with the following name: init.m
Put your code into this file, e.g.,
function stuff = init
stuff = whatever;
end
Call this function like you would any other function:
mystuff = init;
  12 个评论
Rajasmita Sahoo
Rajasmita Sahoo 2023-1-20
did that method work in your case @Mohamed Agha , whatever told by @James Tursa ?
please kindly reply.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Performance and Memory 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by