How can I export my Simulink electrical circuit into a Matlab function?

5 visualizzazioni (ultimi 30 giorni)
I've drawn the following electrical circuit and it's working really well. The thing is that I need to test multiple discrete values of some of the parameters like Load, Ground Resistance, and Length of conductors.
Ideally, I wish to define a function in MATLAB which as input it takes something like Rg, P1, Q1, L and as output it would give me the values of voltages and currents. It would be a [V1, V2, I1, I2] = my_circuit(Rg, P1, P2, Q1, Q2]
Ignore the shortcircuit block.
I don't even know if it possible. Can anyone point me on the right direction?
Thanks in advance

Risposte (1)

Joel Van Sickel
Joel Van Sickel il 18 Set 2023
Modificato: Joel Van Sickel il 18 Set 2023
The easiest approach to this would be to utilize the sim() command. This lets you set parameters, run a simulation and then get results. You can then take it to the next step and do things like generating code from the model but the sim() command is the quickest easierst way to do it and doesn't require any of the coder or compiler products.

Categorie

Scopri di più su Simscape Electrical in Help Center e File Exchange

Prodotti


Release

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by