フィルターのクリア

The command svmtrain in LIBSVM matlab package takes input for values of C and g in quotes as a string value. I want to use the single code svmtrain repetitively by having different values for C and g. But how to do it?

3 ビュー (過去 30 日間)
the command i want to reuse repetitively was:
svmtrain(Label,instance, * * _' -c 12 -g 2 '_**);
Here how do can i change values of 12 and 2 in a kind of loop continuously?

採用された回答

Ced
Ced 2016 年 3 月 23 日
What you essentially need to do is concatenate strings (and convert the number into a string). Let's say you want to test the vector c = [ 12 16 20 ] and g = [ 2 3 4 ](one at a time).
You can then create your option-string directly as:
for i = 1:length(c)
opt = [ '-c ' num2str(c(i)) ' -g ' num2str(g(i)) ];
% now call svmtrain
end
or use sprintf
for i = 1:length(c)
opt = sprintf('-c %i -g %i',c(i),g(i));
% now call svmtrain
end
For me, the second option is more readable, especially if you have a lot of options.
Cheers

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by