Right display of error!

8 views (last 30 days)
Ashish
Ashish on 25 Aug 2014
Commented: Ashish on 26 Aug 2014
I have two variables in my .m file, which calculates- "possible_hrs" and "diff". The error is thrown if the required hours > possible hours.
error('For this Regular working shift, the maximum working time for a ONE-GO step is ',possible_hrs,'hours.', ...
'Please decrease Step Duration weather by' ,diff, ' hours or increase the working hours');
But the MATLAB gives me a warning- "The Format String might not agree with the argument count".
And finally it is not displayed correctly also (in the situation of error). What could be the solution?

Accepted Answer

Julia
Julia on 25 Aug 2014
Hi,
After I read the Matlab help I think this should work:
error('For this Regular working shift, the maximum working time for a ONE-GO step is %d hours. Please decrease Step Duration weather by %d hours or increase the working hours', possible_hrs, diff);
  3 Comments
Julia
Julia on 25 Aug 2014
This works in the command window:
>> error('For this Regular working shift, the maximum working time for a ONE-GO step is %d hours. Please decrease Step Duration weather by %d hours or increase the working hours',24,5)
For this Regular working shift, the maximum working time for a ONE-GO step is 24 hours. Please decrease Step Duration weather by 5 hours or
increase the working hours
Ashish
Ashish on 26 Aug 2014
I just realized that it did work. I guess, was doing something wrong!
Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on Weather and Atmospheric Science in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!