MATLAB: How to store the result of a dos command into a file in matlab

MATLABresult of a dos command into a file in matlab

Hello, I would like to store the result of the dos command into a text file, which i want to read later in matlab. i used the following code
[status, Result] = dos(Iperf_command,'-echo');
fid=fopen('result.txt','w');
fprintf(fid,'%6.2f %12.8f\n',Result);
fclose(fid);
but t didnt work out. Please help me in this regard.Thanks in advance.

Best Answer

the PingLog.txt is the file the output will be written to. At least the standard output; errors might go to a different location.
But if you have already captured the result into Result, then use
fid = fopen('result.xt', 'w');
fwrite(fid, Result);
fclose(fid);