function [] = SamsReport(varargin) % "Sam's Report" - Displays MATLAB objects in an HTML window; % By Sam Berens (S.Berens@sussex.ac.uk); Tuesday 09th August 2016. %% Record disp output: nModels = nargin; format short; diary('Temp.txt'); diary on; for i_Model = 1:1:nModels fprintf('<strong>%s</strong>%c',inputname(i_Model),10) disp(varargin{i_Model}); fprintf('%c%c%c%c%c',10,10,10,10,10) end diary off; %% File mod: FileId_In = fopen('Temp.txt'); TextData = fread(FileId_In); fclose all; Str1 = double('diary on;')'; Str2 = double('diary off;')'; ToCopy = ones(size(TextData)); for i_TextData = (size(TextData,1)-size(Str1,1)+1):-1:1 ToMatch = TextData(i_TextData:(i_TextData+size(Str1,1)-1),1); Match = sum(double(ToMatch == Str1),1) == size(Str1,1); if Match ToCopy(i_TextData:(i_TextData+size(Str1,1)-1),1) = zeros(size(Str1)); end end for i_TextData = (size(TextData,1)-size(Str2,1)+1):-1:1 ToMatch = TextData(i_TextData:(i_TextData+size(Str2,1)-1),1); Match = sum(double(ToMatch == Str2),1) == size(Str2,1); if Match ToCopy(i_TextData:(i_TextData+size(Str2,1)-1),1) = zeros(size(Str2)); end end ToCopy = logical(ToCopy); Html_Body = TextData(ToCopy); Html_Body = Html_Body(1:end,:); Html_Body = Html_Body(1:end-4,:); %% Html_Head = double(sprintf(... '<!DOCTYPE html>%c<html>%c<body style="background-color:#000000;">%c<p style="color:#00ff40;font-family:courier;white-space:pre;">',...# 10,10,10))'; Htlm_End = double(sprintf('%c</p>%c</html>',10,10))'; Html_All = [Html_Head;Html_Body;Htlm_End]; %% Delete old stuff: delete('Temp.txt'); delete('ResultsDisp_*'); %% Write ouput file: FileName_Out = sprintf('ReportDisp_%04d%02d%02d%02d%02d%i.html',round(clock)); FileID_Out = fopen(FileName_Out,'w'); fwrite(FileID_Out,Html_All); fclose all; winopen(FileName_Out); return