There is a function call TreeBagger that can implement random forest. However, if we use this function, we have no control on each individual tree. Can we use the MATLAB function fitctree, which build a decision tree, to implement random forest? Thanks a lot.
I would highly recommend doing some research into the architecture of random forests. There are many sites that provide in depth tutorials on RFs (Implementation in Python).
Quick explanation: take your dataset, bootstrap the samples and apply a decision tree. Within your trees, you want to randomly sample the features at each split. You should not have to build your own RF using fitctree however. You don't want to control each individual tree in the forest. This introduces bias, and the point of the RF is that by bagging many trees, you remove the risk of overfitting.
Define your hyperparameters and let the algorithm do it's thing. Carefully cross-validate to ensure you are not under-fitting.