将另一个 m 文件加载到工作场所不起作用
Loading another m-file to the workplace is not working
我想将一个名为 myfile.m 的特定 m 文件加载到我的 workplace.This matlab 文件中,该文件包含几个我需要加载到我的工作中的数组space.
-------------------------myfile.m---------------- --------------------
r_red=[218,2,1,12,238,106,246,14,26,77,244];
r_green=[65,61,37,247,151,217,229,235,218,2,1];
r_blue =[14,26,77,244,164,131,119,9,222,80,61,228];
在我的工作中 space 我尝试 运行 使用这些代码和其他一些支持代码 arrays.The 我使用的代码如下。
addpath('D:\mydocs'); % This is the place where myfile.m is located.
load myfile.m;
当我 运行 执行此操作时,出现以下错误。
使用负载时出错
ASCII 文件 D:\mydocs\keyfile.m 第 2 行的未知文本
"r_red=[218".
非常感谢您就此提出的任何意见。
谢谢。
问题是 load
用于加载存储在 .mat
文件中的二进制数据或基于文本 (ASCII) 的数据文件。您拥有的是 m 文件中的一个简单脚本,以 .m
结尾。你 load
.mat
个文件,但是你 run
个包含脚本的 m 文件:
run myfile.m;
load(filename) loads data from filename.
If filename is a MAT-file, then load(filename) loads variables in the MAT-File into the MATLAB® workspace.
If filename is an ASCII file, then load(filename) creates a double-precision array containing data from the file.
您的文件都不是。
我想将一个名为 myfile.m 的特定 m 文件加载到我的 workplace.This matlab 文件中,该文件包含几个我需要加载到我的工作中的数组space.
-------------------------myfile.m---------------- --------------------
r_red=[218,2,1,12,238,106,246,14,26,77,244];
r_green=[65,61,37,247,151,217,229,235,218,2,1];
r_blue =[14,26,77,244,164,131,119,9,222,80,61,228];
在我的工作中 space 我尝试 运行 使用这些代码和其他一些支持代码 arrays.The 我使用的代码如下。
addpath('D:\mydocs'); % This is the place where myfile.m is located.
load myfile.m;
当我 运行 执行此操作时,出现以下错误。 使用负载时出错 ASCII 文件 D:\mydocs\keyfile.m 第 2 行的未知文本 "r_red=[218".
非常感谢您就此提出的任何意见。 谢谢。
问题是 load
用于加载存储在 .mat
文件中的二进制数据或基于文本 (ASCII) 的数据文件。您拥有的是 m 文件中的一个简单脚本,以 .m
结尾。你 load
.mat
个文件,但是你 run
个包含脚本的 m 文件:
run myfile.m;
load(filename) loads data from filename.
If filename is a MAT-file, then load(filename) loads variables in the MAT-File into the MATLAB® workspace.
If filename is an ASCII file, then load(filename) creates a double-precision array containing data from the file.
您的文件都不是。