@min min: It is a function not a code, it will not work till you pass P and k to it in command window
@Tamir: It depends on what name you have used to save this file, will be called by that name only,
I have used this code to even encrypt 100 pages of text file, it is working fine
this is the result for what you asked
P='Hello World and Welcome to Matlab cryptogrpahy'
C=Khoor Zruog dqg Zhofrph wr Pdwode fubswrjusdkb