Borrar filtros
Borrar filtros

How to display output from edit text gui?

1 visualización (últimos 30 días)
Tara
Tara el 6 de Mayo de 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 comentarios
Matt Kindig
Matt Kindig el 6 de Mayo de 2013
Editada: Matt Kindig el 6 de Mayo de 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 el 6 de Mayo de 2013
@Matt Kindig: I cannot vote for this useful answer, because you have posted it as a comment.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Language Fundamentals en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by