MDL Files as Text - Change maximum line length?

3 Ansichten (letzte 30 Tage)
Conor Sullivan
Conor Sullivan am 18 Mär. 2021
Beantwortet: Arun am 21 Feb. 2024
I'm using UNIX grep to quickly find specific strings in MDL files. I'm running into trouble when the string of interest is broken up by a newline or line feed character.
When opening a MDL file as text, the maximum length of any line appears to be 123 characters. Is there any way to increase this limit?
I can manually change the line in a text editor, and Matlab seems to open the editied MDL just fine, but when I resave, the line is reverted to 123 characters and line feed.
For example, I'm looking for "function_i_want_to_find", but in the MDL file we get
labelString "[output_flag, output_AAAA, output_BBBB, outtput_CCCC, output_DDDDD, output_EEEE] = function_i_wa"LF
"nt_to_find(input_a,input_b,input_c, input_d)"LF

Antworten (1)

Arun
Arun am 21 Feb. 2024
Hi Conor,
I understand that when you open a MDL file it is wrapped for maximum line length to be 123 characters because of which you are not able to use UNIX grep to find specific strings in MDL files.
Try disabling the “word wrap” view setting or something similar (this setting may vary) based on the editor, which might cause the line change. Disabling the editor settings will help. For mdl files, line length is not limited to 123 characters.
However, while using the UNIX grep, you can use the following command to include line change while matching the string:
$ grep -zoP ‘function_i_want_to_find | use_different_regular_expression_you_want_to_try_with_line_chage” your_model.mdl
This will help match the required string even after the line changes. Here is a screenshot for reference.
You can also use the command “pcregrep -M 'function_i_wa(.|\n)*nt_to_find' your_model.mdl” for similar purpose.
For more information regarding Simulink preference please reference the shared documentation link: https://www.mathworks.com/help/simulink/slref/simulinkpreferences.html
Hope this helps.

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by