Check the fprintf. You can format your output just like you want.
for id=1:num_ids % do something if isempty(stress_value) fprintf('The following ID does not have an assigned stress value: %d\n',id) continue end % do something end
The error function will stop code execution.
The display function only prints the value of the variable, without printing the variable name.