MATLAB:Octave函数“源"的替代方法(导入m文件) [英] MATLAB: alternative of Octave's function 'source' (import m-file)

查看:360
本文介绍了MATLAB:Octave函数“源"的替代方法(导入m文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Octave中,您可以将m文件源导入函数'source'(请参见 http ://octave.sourceforge.net/octave/function/source.html ).我用它来创建许多配置参数并从主文件中获取它.

In Octave you can import a m-file source the function 'source' (see http://octave.sourceforge.net/octave/function/source.html). I use it to create a lot of configuration parameters and source it from the main file.

MATLAB没有函数'source',我找不到替代方法.你有什么主意吗?

MATLAB has no function 'source' and I cannot find an alternative. Do you have any idea?

推荐答案

仅从MATLAB脚本中调用m文件会将其导入到脚本中.

Just calling an m-file from a MATLAB script will import it into the script.

例如如果我有一个脚本configparameters.m,其中我定义了a = 2,则该脚本(在同一目录中)

e.g. If I have a script configparameters.m where I define a=2, the script (in the same directory)

clear all;
configparameters;
disp(a)

将值2打印到屏幕上.

这篇关于MATLAB:Octave函数“源"的替代方法(导入m文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆