get circuit (simulink electrical) output in matlab code

Hello. I have drawn a simple circuit (RLC with sinusoidal input) using electrical simulink.
I have two questions. How can I read circuit output for example resistor voltage and plot it in matlab code? (I know that we can use Sim command to call simulink models in a matlab code). And how can I modify the circuit (simulink model) in the code, for example change the voltage source frequency or add a new element at specific nodes? Many thanks for your time.

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 4 月 19 日

0 投票

See the attached file (saved in R2020a) to see an example of reading the voltage and plotting it in MATLAB. Run the following code to plot the value
sim('sim_model');
plot(out.r_voltage)

4 件のコメント

Mr Noone
Mr Noone 2020 年 4 月 19 日
編集済み: Mr Noone 2020 年 4 月 19 日
@Ameer Hamza , Many thanks for the answer, but I don't see any attachment.
Ameer Hamza
Ameer Hamza 2020 年 4 月 19 日
Mr Noone, check the updated answer. The file is attached.
Mr Noone
Mr Noone 2020 年 4 月 19 日
Thanks.
Ameer Hamza
Ameer Hamza 2020 年 4 月 19 日
Glad to be of help.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSimscape Electrical についてさらに検索

質問済み:

2020 年 4 月 19 日

コメント済み:

2020 年 4 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by