How does it go about implementing pitch shifting without affecting the duration or speed on matlab?
For the speed change: Sample rate is the rate at which samples are read right? So, as per that definition, since you have a higher sample rate, you would be reading more samples in one second. The length of the file remains the same but now since the samples are read faster, the overall length of the file would become slower (with an increase in sampling frequency). 

For the pitch change: Now, let us consider the case of increasing the sampling frequency. I'm sorry for giving a rough explanation for this but imagine increasing the sampling frequency would squish the signal in the time axis since now lesser samples represent the same length in samples. This would mean an increase in frequency, thus resulting in a pitch shift.