ens = fitensemble (X, Y, method, nlearn, students) creates an ensemble model that predicts responses to data. The ensemble consists of models listed in the students.
First part
You must use prior alphabetically your class labels.
So, if the labels are ['A','B'] , you use 'prior',[P(A) P(B)] ,
or if the labels are ['true','false'] , you use 'prior',[P(false) P(true)] ,
or if the labels are [-1 10] , you use 'prior',[P(-1) P(10)] .
The second part
In classnames this parameter is used so that you can call fitensemble for fewer classes in your data.
Imagine you have four classes A,B,C,D , so your Y will look something like this:
Y = [A;A;B;D;B;A;C;A;A;A;D, ... ];
Now you can write 'classnames',['A';'B'], if you want fitensemble for only two classes, and it will be the same as 'classnames',['B';'A'], fitensemble
I know this is a late answer, I hope this helps.
Example
I used the database "fisheriris", which has three classes ( setosa', versicolor , virginica`).
since it has 150 cases and 50 for each class, I randomized the data and selected 100 samples.
load fisheriris rng(12); idx = randperm(size(meas,1)); meas = meas(idx,:); species = species(idx,:); meas = meas(1 : 100,:); species = species(1 : 100,:); trueprior = [ sum(strcmp(species,'setosa')),... sum(strcmp(species,'versicolor')),... sum(strcmp(species,'virginica'))] / 100;
trueprior = [0.32,0.30,0.38] shows true previous probabilities.
In the following code, I prepared three fitensembles , the first with default parameters, so the previous probability is empirical (the same as trueprior ); The second is training with pprior set to trueprior , which will have the same results as the fist (because trueprior is in alphabetical order of class labels). The third one trains with a non-alphabetical order and shows different results than the first two.
ada1 = fitensemble(meas,species,'AdaBoostM2',20,'tree'); subplot(311) plot(resubLoss(ada1,'mode','individual')); title('Resubstitution error for default prior (empirical)'); ada2 = fitensemble(meas,species,'AdaBoostM2',20,'tree','prior',trueprior); subplot(312) plot(resubLoss(ada2,'mode','individual')); title('Resubstitution error for prior with alphabetical order of class labels'); ada3 = fitensemble(meas,species,'AdaBoostM2',20,'tree','prior',trueprior(end:-1:1)); subplot(313) plot(resubLoss(ada3,'mode','individual')); title('Resubstitution error for prior with random order');

I also trained fitensemble only two classes using the classnames option
ada4 = fitensemble(meas,species,'AdaBoostM1',20,'tree','classnames',... {'versicolor','virginica'});
As evidence, AdaBoosM1 , which does not support more than two classes, works great here with only two classes.