conservativeResize() with zero values for the new values
I've solved the problem by using conservativeResizeLike()
int Nt = 0;
Eigen::MatrixXd CO;
CO.setOnes(3+3*Nt, 3+3*Nt);
std::cout << CO << std::endl << std::endl;
Nt = 1;
CO.conservativeResizeLike(Eigen::MatrixXd::Zero(3+3*Nt,3+3*Nt));
std::cout << CO << std::endl << std::endl;
The result
Also, I found out you can set them as ones Eigen::MatrixXd::Ones(3+3*Nt,3+3*Nt)
or identity Eigen::MatrixXd::Identity(3+3*Nt,3+3*Nt)
For Identity
Those values are not so much "trash" values as they are "uninitialized memory" values. It is your responsibility to set them to whatever values make sense to you. It should not be difficult to iterate over the new values and zero them if you wish.