Possible erroneous lint message when using SPRINTF

Hello all,
I am using SPRINTF to format a string for a plot title, like so:
str = sprintf('The title %s', f)
I get the lint message "The function SPRINTF is apparently called with a cell array (argument 2)".
The variable f is defined as such: If the value of another variable n equals 1 then f is defined as a cell array of strings {'1Hz', '2Hz', '3hz'}. If n equals 0 then f is simply a 1x3 character array ['3Hz'].
When I use SPRINTF in the instance above, the value of n is always 0, so f in this case would never be a cell array. Yet MATLAB seems to assume that, because f is sometimes a cell array then it is a cell array (which in this case it is not).
Basically, is there a way of suppressing this message? I like my lint checker to be green and it's bugging me :-)
Thanks,
Louis Vallance

 採用された回答

Walter Roberson
Walter Roberson 2014 年 3 月 26 日

0 投票

Redefine the n = 0 case as f = {'3Hz'} and then sprintf() of f{1}

1 件のコメント

Louis Vallance
Louis Vallance 2014 年 3 月 26 日
Can't believe I didn't see this. Thank you!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Report Generator についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by