我为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>> 我怎么才能解决这个问题?
发布于 2019-05-16 13:23:10
发布于 2019-05-16 13:03:33
对换行符使用\n:
fprintf('Error: Input sizes are not equal\n');https://stackoverflow.com/questions/56169207
复制相似问题