Effacer les filtres
Effacer les filtres

How to display output from edit text gui?

1 vue (au cours des 30 derniers jours)
Tara
Tara le 6 Mai 2013
Hello, i have code bellow
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
input1=get(handles.edit13,'String');
input2=get(handles.edit14,'String');
input3=get(handles.edit15,'String');
parameter_c=str2num(input1);
gamma=str2num(input2);
probability=str2num(input3);
and also i have a code for libsvm
model = cell(numLabels,1);
for k=1:numLabels
model{k} = svmtrain(double(trainLabel==k), trainData, '-c 1 -g 0.2 -b 1');
end
i want to change the '-c 1 -g 0.2 -b 1' it's something like
model = cell(numLabels,1);
for k=1:numLabels
model{k} = svmtrain(double(trainLabel==k), trainData, '-c parameter_c -g gamma -b probability');
end
but it says ??? Attempt to reference field of non-structure array.
'-c 1 -g 0.2 -b 1' is a string,isn't it? What should i do? thank you
  2 commentaires
Matt Kindig
Matt Kindig le 6 Mai 2013
Modifié(e) : Matt Kindig le 6 Mai 2013
You intend to use parameter_c, gamma, and probability as variable names, but you are referring to them as literal strings 'parameter_c', 'gamma', and 'probability'. You need to create a string where the values of the variables are substituted in.
Try this line instead:
model{k} = svmtrain(double(trainLabel==k), trainData, sprintf('-c %d -g %f -b %d', parameter_c, gamma, probability) );
Jan
Jan le 6 Mai 2013
@Matt Kindig: I cannot vote for this useful answer, because you have posted it as a comment.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Language Fundamentals dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by