old_num = '17';
old_base = 8;
new_base = 7;
result = base2base(old_num, old_base, new_base);
fprintf('%i\n', result)
%% !!!!!!! The function must be defined AFTER all other code !!!!!!!!!
function [ b ] = base2base( a, base_from, base_to )
M = base2dec(a, base_from);
n = floor(log10(M) / log10(base_to));
b = zeros(1, n+1);
for i = 0:n
b(n + 1 - i) = mod(floor(M / (base_to^i)), base_to);
end
end % <-------- you need END at the end of the function !!!!!!!!