开发者

matlab: grouping variables for gscatter

I'm a complete Matlab newbie, so please bear with me :) I'm using my friend's vague instructions, so I don't if they are correct.

I have variable named m12 (imported form an .xls file), which is an 61x3 array. No labels.

The first column contains leverages, the second standardised residuals for the training (first 46 rows) and validation (remaining 15 rows) sets of a PLS model.

I want to group those first two columns, so that the training set is represented by blue 'X', and validation set by red 'O', so I put 46 rows of '1's and next 15 rows '2's in the third column.

My friend to开发者_如何转开发ld me to simply type:

group(:,3)

gscatter(m12(:,1), m12(:,2), group, 'br', 'xo')

but when I type

 group(:,3)

I get an "??? Undefined variable group." error.

Can anyone help me?


Just write

group = m12(:,3); 

instead of your first line.

This way, you're defining a vector group that contains all the entries of the third column of m12, i.e. your grouping variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜