How to set and extract node voltage over time in simulink
23 views (last 30 days)
Show older comments
Hello. When I time-transient using simulink, I want to set the voltage value of a specific node and extract the value of the change over time.
For example, when node A is between two resistors, when the initial node A voltage is set to 1V and time-transient, node A voltage is updated according to the circuit over time and I want to know how to extract it. I'd really appreciate it if you could let me know.
0 Comments
Accepted Answer
Rahul
on 2 Jun 2023
Hey there,
As per the snapshot provided by you, I tried to recreate the model using Foundations Library>Electrcial components, a To Workspace block for transferring node voltage sequence to a local workspace named out and a voltage measurement subsystem, whose implementation is described in the second image.
The output voltage of the required node can be extracted simply by connecting the positive terminal of the subsystem to the node itself and the negative one to an electrical reference (ground).
I wasn't able to understand what you meant by dynamically setting the node voltage externally, so I just came up with a model to measure/plot the output voltage of the node you specified.
Then, after connecting the To Workspace block to the subsystem output, I renamed the variable in the block configuration to Vout , which can be accessed in the same workspace/directory using a script file (.m) with the following snippet, where test1.slx is the model name:
% Simulating the model
sim('test1.slx')
% Converting the timeseries data to timetable format
TT = timeseries2timetable(out.Vout);
% Accessing simulation variable 'Vout' using timetable
TT.Properties.DimensionNames{2};
% Column Vector for node voltage
outVoltage = TT.(TT.Properties.DimensionNames{2})
I have attached Model snapshots along with the model files (.slx) for your reference as well.
More Answers (0)
See Also
Categories
Find more on Switches and Breakers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!