如何调用m文件给变量赋值
事先已建立一个数据文件,并将一矩阵数据存入其中。现在我想要将其中的数据赋值给变量x,如下命令不可实现,请高手指点!filename=input('输入数据所在的文件名','s');
x=load(filename);
x
[ 本帖最后由 eight 于 2007-6-16 23:38 编辑 ] =uigetfile('*.txt','Open the text File');
fullname=strcat(pname,fname)
load(fullname) 原帖由 fred9810 于 2007-6-16 15:23 发表 http://www.chinavib.com/forum/images/common/back.gif
事先已建立一个数据文件,并将一矩阵数据存入其中。现在我想要将其中的数据赋值给变量x,如下命令不可实现,请高手指点!
filename=input('输入数据所在的文件名','s');
x=load(filename);
x
这些带有主观因素(即带有输入参数)的问题最好描述清楚:“不可实现”是指什么?程序的出错信息是什么?尽量提供详细的信息,要知道别人的时间也是很宝贵的。建议看看 置顶贴:聚宝盆
新手求助:原来问题没说清楚,重新法帖。对不住各位!
我已将矩阵数据x=[0.30,0.80,0.20 0.28,0.90,0.700.24,0.70,0.10;
0.29,0.75,0.10 0.27,0.85,0.80 0.25,0.80,0.10;
0.30,0.60,0.10 0.27,0.70,0.80 0.26,0.60,0.10;
0.33,0.80,0.15 0.25,0.85,0.75 0.22,0.75,0.10;
0.35,0.50,0.05 0.30,0.60,0.90 0.28,0.55,0.05;
0.33,0.58,0.10 0.30,0.74,0.80 0.27,0.64,0.10;
0.30,0.55,0.05 0.26,0.78,0.90 0.24,0.60,0.05;
0.26,0.85,0.08 0.24,0.90,0.90 0.20,0.70,0.02;
0.33,0.65,0.10 0.26,0.80,0.80 0.23,0.50,0.10;
0.34,0.68,0.15 0.29,0.75,0.80 0.26,0.55,0.05;
0.34,0.60,0.05 0.30,0.75,0.90 0.27,0.55,0.05;
0.32,0.55,0.10 0.31,0.75,0.75 0.28,0.70,0.15;
0.27,0.90,0.05 0.25,0.99,0.90 0.23,0.90,0.05;
0.30,0.89,0.15 0.28,0.95,0.75 0.24,0.90,0.10;
0.34,0.90,0.05 0.29,0.98,0.80 0.26,0.90,0.15]
建立在了一个名为data的m文件中。
现想在程序中调用data文件数据,并将数据中x赋值给另一
变量y,即使得y=x。
我用了如下命令:
filename=input('输入数据所在的文件名','s');
y=load(filename)
输出结果为y=
x:
可是调用y(2,5)时,输出??? Index exceeds matrix dimensions. 我想要输出y(2,5)=0.85
请问问题出在哪里? 原帖由 fred9810 于 2007-6-17 10:57 发表 http://www.chinavib.com/forum/images/common/back.gif
我已将矩阵数据
x=[0.30,0.80,0.20 0.28,0.90,0.700.24,0.70,0.10;
0.29,0.75,0.10 0.27,0.85,0.80 0.25,0.80,0.10;
0.30,0.60,0.10 0.27,0.70,0.80 0.26,0.60,0.10;
0.33,0.80,0.15 0.25,0.85,0.75 0.22 ...
请看看 置顶贴:聚宝盆 中提到的精华贴:写给学习 matlab 的新手们,仔细阅读 原帖由 fred9810 于 2007-6-17 10:57 发表 http://www.chinavib.com/forum/images/common/back.gif
建立在了一个名为data的m文件中。
那你的这个m文件里的具体内容是什么呢?
页:
[1]