path = ("C:\Users\Administrator\Desktop\MGM\0330MGM_instructions_files\try3_0519_PDS_Geoscience\cartOrder\cartorder\REF_26_3.mat") load('wavelengths.mat'); load(path); size_ref_1 = size(Ph,1); size_ref_2 = size(Ph,2); Ph = permute(Ph, [3,2,1]); Ph = Ph(:,:,:); Ph = reshape(Ph, size(Ph,1), size(Ph,2)*size(Ph,3)); data = zeros(size(Ph,1), size(Ph,2)+1); wavelengths = reshape(wavelengths, [], 1); % 将 wavelengths 转换为 n 行 1 列的矩阵data(:, 1) = wavelengths; data(:, 1) = wavelengths; data(:, 2:end) = Ph save('output26_3_try4_0603.asc', 'data', '-ascii');代码是以上这个,怎么解决?已知原始的Ph为850*850*54
时间: 2023-09-06 15:13:09 浏览: 116
MGM.rar_accuracy_mgm_mgm matlab_mgm模型预测_预测检验
5星 · 资源好评率100%
根据您提供的信息,您需要将 `Ph` 的大小调整为 `850*54*850`,并将 `wavelengths` 转换为 `850*1` 的矩阵,以便与 `Ph` 和 `data` 的大小匹配。您可以尝试以下代码:
```
path = "C:\Users\Administrator\Desktop\MGM\0330MGM_instructions_files\try3_0519_PDS_Geoscience\cartOrder\cartorder\REF_26_3.mat";
load('wavelengths.mat');
load(path);
Ph = permute(Ph, [1, 3, 2]); % 调整 Ph 的大小为 850*54*850
Ph = reshape(Ph, size(Ph,1), size(Ph,2)*size(Ph,3));
wavelengths = reshape(wavelengths, [], 1);
data = [wavelengths, Ph]; % 将 wavelengths 和 Ph 合并为一个矩阵
save('output26_3_try4_0603.asc', 'data', '-ascii');
```
这个代码将 `Ph` 的大小调整为 `850*54*850`,将 `wavelengths` 转换为 `850*1` 的矩阵,然后将 `wavelengths` 和 `Ph` 合并为一个矩阵 `data`。最后,将 `data` 保存为 ASC 文件。
阅读全文