Arduino Activation from Matlab

My Arduino is expecting the letter 'D' and then 'enter' to start operation. I have tried the following code with no success. Does anyone know how to solve this problem? Thanks ahead!

delete(instrfindall);
Arduino = serial ('COM3');    
Arduino.BaudRate = 19200;    
Arduino.InputBufferSize=2^16;
fopen(Arduino);           
fprintf(Arduino,'%s' , 'D\n');
fclose (Arduino);  
delete (Arduino);
fprintf(Arduino,'%s' , 'D\r');

Maybe?

Problem solved! The solution was to insert a delay in Matlab after opening the port before writting to the port. Otherwise, Matlab writes to a (still) closed port..

delete(instrfindall);
Arduino = serial ('COM3');   %5-3%on AG machine using Uno  %% delete(instrfindall) 
Arduino.BaudRate = 19200;    % the baud rate with which my data is received 115200
Arduino.InputBufferSize=2^16;
fopen(Arduino);           
startCommand='D';%'D\n';
pause(5);
fprintf(Arduino,'%c',startCommand);
%fprintf(Arduino,'%s', 'cr');
fclose (Arduino);  % closing COM port