Username Remember Me?
Password   forgot password?
   
   
Requesting to pass the class name as a variable to the sdlab function? 
Posted: 02 December 2016 05:58 PM   [ Ignore ]  
Master
RankRankRank
Total Posts:  60
Joined  2010-05-27

Dear developer,

there is a demand to pass the variables to the sdlab for easy creation the dataset through the GUI.

Can you please help provide an example to pass a variable to the sdlab function?

eg. I can use sdlab as follows: lab=sdlab(’class1’,124,’class2’,200,’class3’,300);

then I wanted to use it as the followings:
classname={class1,class2,class3}’;
r1=124; r2=200; r3=300;
lab=sdlab(classname(1),r1,classname(2),r2,classname(3),r3);

this is not working. can you provide an example to achieve this task? thanks!

Profile
 
 
Posted: 05 December 2016 05:54 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  371
Joined  2008-04-26

here is the example:

>> classname={'class1','class2','class3'}

classname 


    
'class1'    'class2'    'class3'

>> r1=124r2=200r3=300;
>> 
lab=sdlab(classname{1},r1,classname{2},r2,classname{3},r3)
sdlab with 624 entries3 groups'class1'(124'class2'(200'class3'(300)

You need to use curly brackets {} to get content of the cell array classname. With the round brackets (as in your example above), you get another cell array. That’s why perClass sdlab did not recognize the name (it was not string).

BTW, if you have sizes available in a vector, you may directly pass it to sdlab constructor:

>> sizes=[124 200 300]

sizes 
=

   
124   200   300

>> lab=sdlab(classname,'sizes',sizes)
sdlab with 624 entries3 groups'class1'(124'class2'(200'class3'(300)

Note the explicit ‘sizes’ option to avoid ambiguity.

Hope it helps,

Pavel

Profile