Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
39 views5 pages

Simulink Circuit Simulation Guide

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views5 pages

Simulink Circuit Simulation Guide

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

To run the code and solve the given circuits in Simulink, follow these steps:

### Running Simulink Models in MATLAB

#### Prerequisites
1. Ensure you have MATLAB and Simulink installed.
2. Open MATLAB.

### Step-by-Step Guide

#### 1. **Open MATLAB**

Launch MATLAB from your desktop or start menu.

#### 2. **Create a New Simulink Model**

For each of the provided codes, follow these instructions:

#### For Tema I

1. **Open a new Simulink model:**


- In MATLAB Command Window, type:
```matlab
open_system(new_system('CircuitModel_Tema1'));
```

2. **Add components and configure them:**

```matlab
% Add components
add_block('powerlib/Elements/AC Voltage Source', 'CircuitModel_Tema1/AC Voltage
Source');
add_block('powerlib/Elements/Series RLC Branch', 'CircuitModel_Tema1/Resistor');
add_block('powerlib/Elements/Series RLC Branch', 'CircuitModel_Tema1/Inductor1');
add_block('powerlib/Elements/Series RLC Branch', 'CircuitModel_Tema1/Inductor2');

% Set parameters
set_param('CircuitModel_Tema1/Resistor', 'Resistance', '3', 'Inductance', '0',
'Capacitance', '0');
set_param('CircuitModel_Tema1/Inductor1', 'Resistance', '0', 'Inductance', '3',
'Capacitance', '0');
set_param('CircuitModel_Tema1/Inductor2', 'Resistance', '0', 'Inductance', '3',
'Capacitance', '0');
set_param('CircuitModel_Tema1/AC Voltage Source', 'Amplitude', '120', 'Frequency', '20',
'Phase', '10');

% Connect components
add_line('CircuitModel_Tema1', 'AC Voltage Source/1', 'Resistor/1');
add_line('CircuitModel_Tema1', 'Resistor/1', 'Inductor1/1');
add_line('CircuitModel_Tema1', 'Inductor1/1', 'Inductor2/1');
add_line('CircuitModel_Tema1', 'Inductor2/1', 'AC Voltage Source/2');
```

3. **Open the Simulink model:**


- In MATLAB Command Window, type:
```matlab
open_system('CircuitModel_Tema1');
```

4. **Run the simulation:**


- Click on the `Run` button in the Simulink model window.

#### For Tema II

1. **Open a new Simulink model:**


- In MATLAB Command Window, type:
```matlab
open_system(new_system('CircuitModel_Tema2'));
```

2. **Add components and configure them similarly to the steps for Tema I.**

3. **Open the Simulink model:**


- In MATLAB Command Window, type:
```matlab
open_system('CircuitModel_Tema2');
```

4. **Run the simulation:**


- Click on the `Run` button in the Simulink model window.

#### For Tema III

1. **Open a new Simulink model:**


- In MATLAB Command Window, type:
```matlab
open_system(new_system('CircuitModel_Tema3'));
```

2. **Add components and configure them:**

```matlab
% Add components
add_block('powerlib/Elements/DC Voltage Source', 'CircuitModel_Tema3/DC Voltage
Source1');
add_block('powerlib/Elements/DC Voltage Source', 'CircuitModel_Tema3/DC Voltage
Source2');
add_block('powerlib/Elements/Resistor', 'CircuitModel_Tema3/Resistor1');
add_block('powerlib/Elements/Resistor', 'CircuitModel_Tema3/Resistor2');
add_block('powerlib/Elements/Current Source', 'CircuitModel_Tema3/Dependent
Source');
add_block('powerlib/Elements/Resistor', 'CircuitModel_Tema3/Load Resistor');

% Set parameters
set_param('CircuitModel_Tema3/DC Voltage Source1', 'Voltage', '80');
set_param('CircuitModel_Tema3/DC Voltage Source2', 'Voltage', '90');
set_param('CircuitModel_Tema3/Resistor1', 'Resistance', '10');
set_param('CircuitModel_Tema3/Resistor2', 'Resistance', '20');
set_param('CircuitModel_Tema3/Dependent Source', 'Current', '2*Io');
set_param('CircuitModel_Tema3/Load Resistor', 'Resistance', '40');

% Connect components
add_line('CircuitModel_Tema3', 'DC Voltage Source1/1', 'Resistor1/1');
add_line('CircuitModel_Tema3', 'Resistor1/1', 'Resistor2/1');
add_line('CircuitModel_Tema3', 'Resistor2/1', 'Dependent Source/1');
add_line('CircuitModel_Tema3', 'Dependent Source/1', 'Load Resistor/1');
add_line('CircuitModel_Tema3', 'Load Resistor/1', 'DC Voltage Source2/2');
```

3. **Open the Simulink model:**


- In MATLAB Command Window, type:
```matlab
open_system('CircuitModel_Tema3');
```

4. **Run the simulation:**


- Click on the `Run` button in the Simulink model window.

### Collecting Results

1. **Add Scopes and Measurement Blocks:**


- Use `Scope` blocks to visualize voltages and currents.
- Use `Voltage Measurement` and `Current Measurement` blocks at relevant points.

2. **Configure Scopes:**
- Double-click on the `Scope` blocks to open and configure them as needed.

3. **Run the Simulation and Analyze Results:**


- After running the simulation, observe the results on the `Scope` blocks.
- Adjust parameters and re-run if necessary to obtain the required results.

### Example Code to Run in MATLAB Command Window

```matlab
% Open a new Simulink model for Tema I
open_system(new_system('CircuitModel_Tema1'));

% Add and configure components


add_block('powerlib/Elements/AC Voltage Source', 'CircuitModel_Tema1/AC Voltage
Source');
add_block('powerlib/Elements/Series RLC Branch', 'CircuitModel_Tema1/Resistor');
add_block('powerlib/Elements/Series RLC Branch', 'CircuitModel_Tema1/Inductor1');
add_block('powerlib/Elements/Series RLC Branch', 'CircuitModel_Tema1/Inductor2');

% Set parameters
set_param('CircuitModel_Tema1/Resistor', 'Resistance', '3', 'Inductance', '0', 'Capacitance',
'0');
set_param('CircuitModel_Tema1/Inductor1', 'Resistance', '0', 'Inductance', '3',
'Capacitance', '0');
set_param('CircuitModel_Tema1/Inductor2', 'Resistance', '0', 'Inductance', '3',
'Capacitance', '0');
set_param('CircuitModel_Tema1/AC Voltage Source', 'Amplitude', '120', 'Frequency', '20',
'Phase', '10');

% Connect components
add_line('CircuitModel_Tema1', 'AC Voltage Source/1', 'Resistor/1');
add_line('CircuitModel_Tema1', 'Resistor/1', 'Inductor1/1');
add_line('CircuitModel_Tema1', 'Inductor1/1', 'Inductor2/1');
add_line('CircuitModel_Tema1', 'Inductor2/1', 'AC Voltage Source/2');

% Open the model


open_system('CircuitModel_Tema1');

% Run the simulation


set_param('CircuitModel_Tema1', 'SimulationCommand', 'start');
```

Repeat similar steps for Tema II and Tema III by replacing the model name and component
parameters accordingly.

You might also like