我试图在GUI matlab中应用神经网络函数。下标指数必须是神经网络中的实数正整数或逻辑值matlab
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
P = load('data.mat','Z');
nR = size(P.Z,2);
min_P = min(P.Z,[],2);
max_P = max(P.Z,[],2);
minmax = [min_P, max_P];
P = ((0.8*(P.Z - repmat(min_P,1, nR))./repmat(max_P - min_P,1,nR))) + 0.1;
Px = load('minmax.txt');
net = newff(minmax(Px),[3 9 4],{'logsig','tansig','logsig'},'trainrp');
net.IW{1,1} = load('bobot1.txt');
net.b{1} = load('bias1.txt');
net.LW{2,1} = load('bobot2');
net.b{2} = load('bias2');
net.LW{3,2} = load('bobot3');
net.b{3} = load('bias3.txt');
[Y] = sim(net,P);
result = round(Y);
sum_result= sum(result);
normal = (sum(sum_result(:) == 0));
set(handles.edit1,'String',num2str(normal));
,但我不断收到此错误:
??? Subscript indices must either be real positive
integers or logicals.
Error in ==> test>pushbutton1_Callback at 95
net = newff(minmax(Px),[3 9
4],{'logsig','tansig','logsig'},'trainrp');
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> test at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)test('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
命令工作正常的训练和测试环节,我不知道为什么它在GUI发生的事情。 此外minmax数据应该包含在0-0.9范围内的数据,因为我的数据在该范围内。先谢谢你。
minmax data:
1.0054496e-001 1.0803815e-001
1.0000000e-001 1.0490463e-001
3.8269755e-001 9.0000000e-001
你可以显示'minmax.txt'的内容和行'Px = load('minmax.txt');' – mhopeng
Plese检查我的更新@mhopeng。我已经上传了我的minmax数据,但我并不真正了解您对Px –
行的结果的请求,请立即在加载语句后加上'disp(Px)',以验证您是否从文本中获得了期望的矩阵文件。 – mhopeng