(如果只有一个)的问题是在你导入数据到.mat文件。如果我提供的文件做数据=负载(“sc_8days.mat”);data =数据。sc8days;[nx、纽约、d] =大小(数据);显示亮度图像(数据(:,:1));我得到这个无稽之谈:[![在这里输入图像描述][1]][1]和d = 23日MOD10C2数据只有四个乐队:Eight_Day_CMG_Snow_Cover, Eight_Day_CMG_Cloud_Obscured, Eight_Day_CMG_Clear_Index, Snow_Spatial_QA(见【产品规格】[2])。然而,如果我直接从.hdf加载数据和情节文件共享,数据= hdfread (“MOD10C2.A2000185.006.2016068190452.hdf”、“Eight_Day_CMG_Snow_Cover”);显示亮度图像(数据);我:[![enter image description here][3]][3] Which does makes sense and show the actual data. Therefore, the way you are importing the data into your .mat file is messing things up. The error is in this line B2(i,j,1:24) = reshape(Eight_Day_CMG_Snow_Cover{i,j},[1 3 2]); Because you are assigning the pixel i,j of each file using data from one file only, and also that should generate and error, I'm not quite sure how this code can run, as the size of Eight_Day_CMG_Snow_Cover is Kx1 and you are attempting to access elements i,j. Anyway, that way is too cumbersome, avoid reshaping and using cell arrays by importing like this: hdfvars = {'Eight_Day_CMG_Snow_Cover', 'Eight_Day_CMG_Clear_Index',... 'Eight_Day_CMG_Cloud_Obscured', 'Snow_Spatial_QA'}; projectdir = 'E:\test\hdf test'; dinfo = dir( fullfile(projectdir, '*.hdf')); num_files = length(dinfo); filenames = fullfile(projectdir,{dinfo.name}); Eight_Day_CMG_Snow_Cover = zeros(3600,7200,num_files); Eight_Day_CMG_Clear_Index = zeros(3600,7200,num_files); Eight_Day_CMG_Cloud_Obscured = zeros(3600,7200,num_files); Snow_Spatial_QA = zeros(3600,7200,num_files); for K = 1 : num_files this_file = filenames{K}; Eight_Day_CMG_Snow_Cover(:,:,K) = hdfread(this_file, hdfvars{1}); Eight_Day_CMG_Clear_Index(:,:,K) = hdfread(this_file, hdfvars{2}); Eight_Day_CMG_Cloud_Obscured(:,:,K) = hdfread(this_file, hdfvars{3}); Snow_Spatial_QA(:,:,K) = hdfread(this_file, hdfvars{4}); end So in this case, the variable Eight_Day_CMG_Snow_Cover contains what you wanted to put in B2. [1]: https://i.stack.imgur.com/8M5kw.png [2]: https://nsidc.org/data/mod10c2 [3]: https://i.stack.imgur.com/ck4xl.png
Baidu
map