필터 지우기
필터 지우기

How to display output from edit text gui?

조회 수: 1 (최근 30일)
Tara
Tara 2013년 5월 6일
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에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by