Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

i have code in gui and if condition does's work why? please help me

1 vue (au cours des 30 derniers jours)
meemee meemee
meemee meemee le 21 Avr 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
M = xlsread('D:\traindata.xls')
N = xlsread('D:\testdata1.xls')
Training_set = M(1:100,2:10)
%specify training set
Target_set = M(1:100,10)
%specify target set
Testing_set = N(1,2:10)
%index=N(:,10)==0002-1;
%specify Testing set
Testing_Target_Set = N(1,11)
%specify Testing set,Target
%X = mapstd(Training_set');
%Y = mapstd(Target_set');
mynetwork = newrb(Training_set',Target_set',0,0.5,100,25)
%newrb(P,T,goal,spread,MN,DF) takes two of these arguments,
%PR x Q matrix of Q input vectors
%TS x Q matrix of Q target class vectors
%goalMean squared error goal (default = 0.0
%spreadSpread of radial basis functions (default = 1.0
%MNMaximum number of neurons (default is Q)
%DFNumber of neurons to add between displays (default = 25)
mynetwork.trainFcn='trainlm';
mynetwork.trainparam.min_grad=0.00000001;
mynetwork.trainparam.epochs=100;
mynetwork.trainparam.ir=0,4;
mynetwork.trainparam.max_fail=20;
%save mynetwork
D=sim(mynetwork,Testing_set')
%simulate network
xlswrite('D:\testdata1.xls',D',2)
%xlswrite(filename, M, sheet) writes matrix M to the specified worksheet sheet in the file filename
if D==1
L='Not Existing'
set(handles.text3,'String',L);
elseif D==2
K='Existing'
set(handles.text3,'String',K);
end

Réponses (1)

Walter Roberson
Walter Roberson le 21 Avr 2019
radial basis networks are function approximations, and will seldom return exact integers -- especially since we do not know that the training targets are 1 or 2.
You should put in a breakpoint after simulation and look closely at the output D to see if it is exactly 1 or 2.
  2 commentaires
meemee meemee
meemee meemee le 22 Avr 2019
I need the correct syntax for if conditions in this code
Walter Roberson
Walter Roberson le 22 Avr 2019
Put in a breakpoint in the code, and examine to see what values are present for D. Look carefully, including looking at
D - floor(D)
to detect values that display like integers but are slightly different than an integer.
Your should attach your data files so other people can test.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by