In the ztest.m, when performing one-tailed tests ("right" or "left"), the calculated p-value is stored in a local variable p but never assigned to the output variable pval. This causes the function to return an error.
x = normrnd(10, 2, 100, 1);
[h, pval] = ztest(x, 10, 2, "tail", "right");
disp("Hypothesis test result (h): "), disp(h);
disp("p-value: "), disp(pval);
>> my
error: 'pval' undefined near line 152, column 15
error: called from
ztest at line 152 column 3
my at line 5 column 2