%% 原始光谱使用SPA选取特征波段并选取训练集和测试集
% figure;
% bar(SPA.COSS,'b','edgecolor','w');
% xlabel('variable index');
% xlim([0 41]);
% ylabel('COSS');
% title('Variable Importance Plot');
% figure;
% plotspa(SPA,SPA.RankedVariable(1));
% p=SPA.p(SPA.RankedVariable(1)); % the p-value of a given variable
[var_sel,~] = spa(data_ys_train,data_ys_train_label,data_ys_test,data_ys_test_label,7,20,0);
figure
plot(data_yshzb,data_ys_train(1,:));hold,grid;
plot(data_yshzb(var_sel),data_ys_train(1,var_sel),'s');
legend('First calibration object','Selected variables');
xlabel('Wavelength index');
hold off;
data_ys_train_spa = data_ys_train(:,var_sel); % 将提取的特征波段的反射率提取出来
data_ys_test_spa = data_ys_test(:,var_sel);
错误使用 spa
输入参数太多。
在运行第一行程序就出现了这个问题,该怎么办呢