The inbuilt code "bode " is not working

6 次查看(过去 30 天)
I was trying to run the bode.
but it showed this.
Error using DynamicSystem/bode (line 96)
Incorrect number of parameters supplied for 'Controllib:plots:strBodeDiagram'. Expected 0 but found 1.
Error in VOUT_VIN_bode (line 42)
bode(sys)
This is my code: (The project name is VOUT_VIN_bode)
[SL: snipped the code for the bode method of DynamicSystem objects. Please do not post MathWorks function files. I also formatted the code above as code instead of text.]
MATLAB Version: 9.8.0.1396136 (R2020a) Update 3
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
How can i fix it???
Can anyone help me to resolve this?
Thank you
  4 个评论
Walter Roberson
Walter Roberson 2021-5-27
You probably have a function on your path that is interfering with one of the functions used by bodeplot() [which is called by bode()] . It would take a bunch of debugging to figure out exactly where the problem was. Using
dbstop if caught error
would help.
But before you do that, experiment with
restoredefaultpath; rehash toolboxcache
if the code works after that, then definitely something on your MATLAB path is interfering.
jimmygc lin
jimmygc lin 2021-5-28
编辑:jimmygc lin 2021-5-28
I run this restoredefaultpath; rehash toolboxcache it didn't work.
after that i run dbstop if caught error And then run my code.
this code is in (matlab\toolbox\shared\controlib\general\+ctrlMsgUtils\message.m)
and then i click continue
this code is in (matlab\toolbox\shared\controlib\general\+ctrlMsgUtils\message.m)
and then i click continue
this code is in (matlab\toolbox\shared\controlib\engine\@DynamicSystem\bodeplot.m)
and then i click continue
this code is in (matlab\toolbox\matlab\helptools\+helpUtils\+csh\helpviewFactory.m)
and then i click continue
this code is in (matlab\toolbox\shared\controlib\engine\@DynamicSystem\bode.m)
and then

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2021-5-27
The same code works here, and runs without error, with either bode or bodeplot.
I switched from bode to bodeplot because bodeplot has more options. I also deleted the bode function code here.
L1 = 91.54e-6;
L2 = 91.36e-6;
RL1 = 0.16 ;
RL2 = 0.15 ;
C1 = 0.042996e-6;
C2 = 0.043091e-6;
Rc1 = 0 ;
Rc2 = 0 ;
Lp = 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0 2.326e+07 0 x6 0 0 0 0 0 0 0 2.321e+07 x7 0 0 1.103e+04 -1074 -1.103e+04 1074 -1765 161.2 x8 0 0 -1074 1.105e+04 1074 -1.105e+04 171.9 -1658 B = u1 x1 1e+05 x2 0 x3 0 x4 0 x5 0 x6 0 x7 0 x8 0 C = x1 x2 x3 x4 x5 x6 x7 x8 y1 0 30 0 0 0 0 0 0 D = u1 y1 0 Continuous-time state-space model.
opts = bodeoptions;
opts.Grid = 'on';
bodeplot(sys, opts) % ---------------This is the (line 42)
I do not advise copying the code for bode or any other MATLAB functions and including them with your own code, since they likely have other dependencies that they may not be able to easily locate from the directories that run your code. Run them as functions from the directories where they were installed. If the code you posted is the code that threw the error, this could be the problem.
.
  9 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Control System Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by