finished up matlab printing so that it works for complex logic