state space Input port size problems
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I'm trying to replicate a matlab function in simulink and I cant figure how to.
When in matlab the size of the input arguments is not relevant, but when in simulink I can't use the same set of data
Attached are the 2 models, the simulink and matlab
1 Commento
Sam Chak
il 24 Mag 2024
Hi @Lorenzo
Have you resolved the issue? In the Simulink model, the input to the State-Space block is incorrectly specified. The initial values of the states are also not specified in the State-Space block.
Risposte (1)
Sayan
il 27 Mag 2024
Hi Lorenzo,
I could reproduce your issue. The issue is due to how the value of "delta" is passed to the "State-Space" block. The steps to resolve the issue are as follows:
- The sample time of Simulink model should be the same as it is specified in the MATLAB script, which is 0.01 and change the solver setting to "Fixed-Step".
- The stop time of the Simulink model needs to be the same as the total time mentioned in the script, i.e., 3 seconds.
- The "State-Space" block accepts the input of width, the same as the number of columns in the B and D matrices. In this case, the value of width is 1. You can find the same in the following documentation:
I have modifed the code inside the "MATLAB Function" block which will output the expected input for the "State-Space" block. After the modification I could get the same output as of the MATLAB script.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1704536/image.png)
The modified model is attached herewith. Please run the model after loading the values of A,B,C,D. You can do it by running your MATLAB script followed by the model.
Hope this resolves your issue.
0 Commenti
Vedere anche
Categorie
Scopri di più su Additional Math and Discrete in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!