将一个m文件中的变量的值调用到另一个m文件中

时间:2013-03-27 18:09:14

标签: matlab

我有一个名为motor_model.m的m文件。我有另一个名为controller.m的m文件,我在第一行调用motor_model.m。现在motor_model.m的输出是稳态电流,它存储在名为I_steadystate的变量中,其值需要在controller.m中调用。

你能告诉我如何做到这一点的代码吗?

1 个答案:

答案 0 :(得分:0)

在m文件controller.m中:

function [] = controller()
steadyState = motor_model()

在m文件motor_model.m

function [I_steadystate] = motor_model()
I_steadystate = 0; % 0 is an example. I_steadyState should be defined somewhere in your code.