function [res] = reformat (c) %reformat c = strrep (c, 'D(f)', '`@@`(D,1)(f)'); id = [0, (strfind (c, '+')), (1 + length (c))]; for n = [1 : (length (id) - 1)] cc{n} = c([(id(n) + 1) : (id(n + 1) - 1)]); if (cc{n}(1) == '`') cc{n} = ['1*' cc{n}]; end id_2 = [0, (strfind (cc{n}, '*')), (1 + length (cc{n}))]; tc = {}; for m = [1 : (length (id_2) - 1)] tc{m} = cc{n}([(id_2(m) + 1) : (id_2(m + 1) - 1)]); end dc{n} = tc; end res = [' ';' ';' ']; for n = [1 : (length (dc))] res = [res [' '; ' + '; ' ']]; if ~((dc{n}{1}(1) == '1') && ((length (dc{n}{1})) == 1)) res = [res [(blanks (3 + length (dc{n}{1}))); ... ['' dc{n}{1} ' * ']; ... (blanks (3 + length (dc{n}{1})))]]; end res = [res ['^'; 'f'; ' ']]; dc{n}{2}([(end - 9) : end]) = []; dc{n}{2}([1 : 7]) = []; res = [res [(blanks (length (dc{n}{2}))); (blanks (length ... (dc{n}{2}))); dc{n}{2}]]; for m = [3 : (length (dc{n}))] if (dc{n}{m}(end) == ')') dc{n}{m} = [dc{n}{m} '^ ']; end p = find (dc{n}{m} == '^'); exs = dc{n}{m}([(p + 1) : end]); p = find (dc{n}{m} == ')'); nds = dc{n}{m}([8 : (p(1) - 1)]); mls = max (length (exs), length (nds)); exs([(end + 1) : (mls + 1)]) = ' '; nds([(end + 1) : (mls + 1)]) = ' '; exs(end) = []; nds(end) = []; res = [res [[' ' exs]; ['f' (blanks (length (exs)))]; [' ' nds]]]; end end res(:,2:3) = [];