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?

 採用された回答

Julia
Julia 2014 年 8 月 25 日

1 投票

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 件のコメント

Ashish
Ashish 2014 年 8 月 25 日
In this case, %d will be taken as a comment. I don't think it is working as I want!
Thanks for your reply though!
Julia
Julia 2014 年 8 月 25 日
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 2014 年 8 月 26 日
I just realized that it did work. I guess, was doing something wrong!
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2014 年 8 月 25 日

コメント済み:

2014 年 8 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by