Function or variable 'ms1' not recognized

4 visualizzazioni (ultimi 30 giorni)
Xiaoning.Wang
Xiaoning.Wang il 21 Giu 2025
Risposto: Shishir Reddy il 27 Giu 2025
matlab2022b生成嵌入式代码报错
Function or variable 'ms1' not recognized
本人是手动点击生成代码(Ctrl+B),并没有想过的脚步,
I manually clicked to generate the code (Ctrl+B) and did not take any steps forward,
Simulink会有时候弹出这个问题,我认为是simulink 自身的问题
Simulink sometimes pops up this issue, and I think it's a problem with Simulink itself
大家有没有遇到过类似的
Have you ever encountered something similar

Risposte (1)

Shishir Reddy
Shishir Reddy il 27 Giu 2025
The error "Function or variable 'ms1' not recognized" usually means that Simulink or MATLAB cannot find a definition for 'ms1' in the current context. This is likely not a bug in Simulink itself, but rather due to one of the following -
1. Missing Workspace Variable: If 'ms1' is supposed to be a variable, make sure it is defined in the MATLAB base workspace before generating code (Ctrl+B). This can be checked by typing 'whos' in the Command Window.
2. Unresolved Block/Function Name: If 'ms1' refers to a block or model component, make sure it exists in your model and is correctly referenced. Sometimes renaming or deleting blocks can leave stale references.
3. Model Callbacks or Scripts: Check if your model relies on any 'InitFcn' callbacks or 'LoadFcn' scripts to initialize variables like 'ms1'. If those scripts are not executed, the variable might not exist.
I hope this helps

Categorie

Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by