Is there a way to remove unnecessary square brackets from a script automatically?

4 ビュー (過去 30 日間)
Dan Getz
Dan Getz 2017 年 7 月 28 日
コメント済み: Dan Getz 2017 年 7 月 28 日
I have a group of 20 or so scripts that I am trying to clean up and improve runtime performance. All of them have a similar error across about 30 or 40 lines per script. The code works, but I am getting this error message for each one. "Use of brackets [] is unnecessary. Use parenthesis to group, if needed." I can manually go through and remove them, but that's pretty tedious and I don't want to do it for all 20 scripts. Is there an existing function written that will automatically fix this so I don't have to manually correct this error?
Here is a sample of the code:
batt_day = [zeros(length(days),1)];
rain_day = [zeros(length(days),1)];
airT_day = [zeros(length(days),1)];
RH_avg_day = [zeros(length(days),1)];
WS_avg_day = [zeros(length(days),1)];
SlrCM_avg_day = [zeros(length(days),1)];
SlrMJ_tot_day = [zeros(length(days),1)];
tsoil6in_day = [zeros(length(days),1)];
tsoil1ft_day = [zeros(length(days),1)];
tsoil2ft_day = [zeros(length(days),1)];
tsoil3ft_day = [zeros(length(days),1)];
tsoil4ft_day = [zeros(length(days),1)];
  2 件のコメント
Stephen23
Stephen23 2017 年 7 月 28 日
編集済み: Stephen23 2017 年 7 月 28 日
Simplest solution: Use Notepad++ and its "Find in Files" operation and the "Replace with" option.
Dan Getz
Dan Getz 2017 年 7 月 28 日
I don't know why I didn't think of that. Genius thanks.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by