【发布时间】:2019-05-16 13:00:25
【问题描述】:
我为pyhtagorean值写了一个小函数:
function c = pyth(a,b)
% Takes two inputs of same size and returns the pythagorean of the 2 inputs
if size(a) == size(b) % checks for same size
c = sqrt(a.*a + b.*b); % calculates the pythagorean value
else
fprintf('Error: Input sizes are not equal'); % returns if sizes are not the same
end
它可以正常工作,但是在它返回后,“>>”与我的输出位于同一行,而不是输出下方的新行。这仅适用于fprintf。这里:
>> pyth([1 2;3 4],[5 6;7 8])
ans =
5.0990 6.3246
7.6158 8.9443
>>
>> pyth([1 2],[1 2;3 4])
Error: Input sizes are not equal>>
我该如何解决这个问题?
【问题讨论】:
标签: matlab console printf newline error-logging