Using system for doing ssh inside a script is not a good idea. You can use this file exchange submission to establish an ssh connection to a machine from MATLAB. You can refer to detailed examples included insides the referred file exchange submission. For your case, you can run
ssh2_simple_command(hostname, username, password, 'cd palm/currentversion; ... mrun -d example neutral -b -h xxxxx -K parallel -X 48 -T 24 -t 1800 -q xxxx.p -r "d3# ts# pr# xy#"');
this will run the command, print the terminal result and close the connection. If you want to main the connection you will need advanced setup as given in example file.