【问题标题】:Load a file inside a function in matlab在matlab中的函数内加载文件
【发布时间】:2013-07-12 01:14:02
【问题描述】:

我尝试在函数中加载文件,如下所示:

function dy = rates(t,y)
    w= load(ang_rates) 

   for i=1:8538

          wx=w(i,1)

          dy = zeros(8538,1);   

          dy = wx+sin(phi)*tan(theta)*wy+cos(phi)*tan(theta)*wz;


      end
end

但它给出了以下错误。它也不会在工作区中显示文件名。

??? Undefined function or variable 'ang_rates'.

Error in ==> rates at 4
    data = load(ang_rates)  %# Initialize data with the .MAT file contents

请注意,该文件与函数位于同一文件夹中。

【问题讨论】:

    标签: matlab file matlab-load


    【解决方案1】:

    你可能正在寻找

    load('ang_rates.mat')
    

    或同等的

    load ang_rates  
    

    在您的示例中,您尝试使用存储在变量 ang_rates 中的名称加载某些内容(当然不存在)。请务必注意函数语法和命令行语法之间的区别。

    【讨论】:

      猜你喜欢
      • 2013-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-25
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多