How to display output from edit text gui?

1 次查看(过去 30 天)
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 个评论
Matt Kindig
Matt Kindig 2013-5-6
编辑:Matt Kindig 2013-5-6
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 2013-5-6
@Matt Kindig: I cannot vote for this useful answer, because you have posted it as a comment.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Language Fundamentals 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by