我的代码不能运行

20次浏览(最近30天)
Seemant女子
Seemant女子 大约22小时前
回答: 图像分析 约16小时前
年= 2009:2017
一年指数= - 2008
一年struct = load(['D:\DataStation\hr ',num2str(ye), '\mat\站。垫”)
站= 1:30
eval (["station double = year struct.station_',num2str(station),';'); "
Station double = Station double (1:8760,:);
Data (:,:,station,year) = station double
结束
结束

答案(2)

Chunru
Chunru 约16小时前
编辑:Chunru 约16小时前
这是我的最佳猜测。
年= 2009:2017
year_index = - 2008变量名中没有空格
Year_struct = load([“D: \ DataStation \人力资源”num2str(年)“\垫\ station.mat”]);
站= 1:30
eval ([“station_double = year_struct.station_”num2str(站),“;”]);
Station_double = Station_double (1:8760,:);
Data (:,:, station, year_index) = station_double;
结束
结束

图像分析
图像分析 大约10小时前
我是这么做的:
撰写= 2009:2017
yearIndex =撰写- 2008;变量名中没有空格
fullFileName = sprintf (' D: / DataStation /人力资源% D /垫/ station.mat '、撰写);
如果isfile (fullFileName)
将.mat文件加载到一个结构中。
yearStruct =负载(fullFileName);
%获取所有字段名'station_1', 'station_2'等到单元格数组中
fn =字段名(yearStruct);
站位= 1:长度(fn)
获取这个特定的字段名。
thisFieldName = fn{站};
%在这个字段中获取2d数组。
thisMatrix = yearStruct。(thisFieldName);
裁掉一部分。
station_double = thisMatrix (1:8760,:);
将这个矩阵加入到我们的4-D数组中。
data(:,:, station, yearIndex) = station_double;
结束
其他的
warningMessage = sprintf ('警告:文件未找到:\n%s', fullFileName);
uiwait (warndlg (warningMessage));
结束
结束

社区寻宝

在MATLAB中心找到宝藏,并发现社区如何可以帮助你!

开始狩猎!