ENGINEERING PROJECT

Matlab/Simulink Program

5:18 PM

Function of Block: To Workspace

Posted by Shahrul




Figure below shows To Workspace Blocks


  • To Workspace
Write data to the workspace


  • Library
Sinks


  • Description
The To Workspace block writes its input to the workspace. The block writes its output to an array or structure that has the name specified by the block's Variable name parameter. The Save format parameter determines the output format.


  • Array
Selecting this option causes the To Workspace block to save the input as an N-dimensional array where N is one more than the number of dimensions of the input signal. For example, if the input signal is a 1-D array (i.e., a vector), the resulting workspace array is two-dimensional. If the input signal is a 2-D array (i.e., a matrix), the array is three-dimensional.

The way samples are stored in the array depends on whether the input signal is a scalar or vector or a matrix. If the input is a scalar or a vector, each input sample is output as a row of the array. For example, suppose that the name of the output array is simout. Then, simout(1,:) corresponds to the first sample, simout(2,:) corresponds to the second sample, etc. If the input signal is a matrix, the third dimension of the workspace array corresponds to the values of the input signal at specified sampling point. For example, suppose again that simout is the name of the resulting workspace array. Then, simout(:,:,1) is the value of the input signal at the first sample point; simout(:,:,2) is the value of the input signal at the second sample point; etc.

The amount of data written and the time steps at which the data is written are determined by block parameters:

  • The Limit data points to last parameter indicates how many sample points to save. If the simulation generates more data points than the specified maximum, the simulation saves only the most recently generated samples. To capture all the data, set this value to inf.

  • The Decimation parameter allows you to write data at every nth sample, where n is the decimation factor. The default decimation, 1, writes data at every time step.

The Sample time parameter allows you to specify a sampling interval at which to collect points. This parameter is useful when you are using a variable-step solver where the interval between time steps might not be the same. The default value of -1 causes the block to inherit the sample time from the driving block when determining the points to write. See "Specifying Sample Time" in the online documentation for more information.

During the simulation, the block writes data to an internal buffer. When the simulation is completed or paused, that data is written to the workspace. Its icon shows the name of the array to which the data is written.


  • Structure
This format consists of a structure with three fields: time, signals, and blockName. The time field is empty. The blockName field contains the name of the To Workspace block. The signals field contains a structure with three fields: values, dimensions, and label. The values field contains the array of signal values. The dimensions field specifies the dimensions of the values array. The label field contains the label of the input line.


  • Structure with Time
This format is the same as Structure except that the time field contains a vector of simulation time steps.


  • Using Saved Data with a From Workspace Block
If the data written using a To Workspace block is intended to be played back in another simulation using a From Workspace block, use the Structure with Time format to save the data.


Examples

In a simulation where the start time is 0, the Limit data points to last is 100, the Decimation is 1, and the Sample time is 0.5. The To Workspace block collects a maximum of 100 points, at time values of 0, 0.5, 1.0, 1.5, ..., seconds. Specifying a Decimation value of 1 directs the block to write data at each step.

In a similar example, the Limit data points to last is 100 and the Sample time is 0.5, but the Decimation is 5. In this example, the block collects up to 100 points, at time values of 0, 2.5, 5.0, 7.5, ..., seconds. Specifying a Decimation value of 5 directs the block to write data at every fifth sample. The sample time ensures that data is written at these points.

In another example, all parameters are as defined in the first example except that the Limit data points to last is 3. In this case, only the last three sample points collected are written to the workspace. If the simulation stop time is 100, data corresponds to times 99.0, 99.5, and 100.0 seconds (three points)



  • Data Type Support
The To Workspace block can save real or complex inputs of any data type supported by Simulink, including fixed-point data types, to the MATLAB workspace.


  • Parameters and Dialog Box



  • Variable name
The name of the array that holds the data.


  • Limit data points to last
The maximum number of input samples to be saved. The default is inf samples.


  • Decimation
A decimation factor. The default is 1.


  • Sample time
The sample time at which to collect points. See "Specifying Sample Time" in the online documentation for more information.


  • Save format
Format in which to save simulation output to the workspace. The default is structure.


  • Log fixed-point data as a fi object
Select to log fixed-point data to the MATLAB workspace as a Simulink Fixed-Point fi object. Otherwise, fixed-point data is logged to the workspace as double.


Characteristics



Thank You..

4:48 PM

Function of Block: MUX

Posted by Shahrul




Figure below show the Mux block


  • Mux
Combine several input signals into a vector


  • Library
Signal Routing


  • Description
The Mux block combines its inputs into a single vector output. An input can be a scalar or vector signal. All inputs should be of the same data type and numeric type.

Note: The Mux block allows you to connect signals of differing data and numeric types and matrix signals to its inputs. In this case, the Mux block outputs a bus signal combining the inputs. In other words, the Mux block behaves like a Bus Creator block. Nevertheless, you should use Bus Creator blocks in such cases to ensure that your model will run in future releases of Simulink, which may not support the use of Mux blocks as Bus Creators. If your model currently uses Mux blocks as Bus Creators, you may want to consider replacing the Mux blocks with equivalent Bus Creator blocks (see Mux blocks used to create bus signals for more information).


The Mux block's Number of Inputs parameter allows you to specify input signal names and sizes as well as the number of inputs. You can use any of the following formats to specify this parameter:

  • Scalar
Specifies the number of inputs to the Mux block. When this format is used, the block accepts scalar or vector signals of any size. Simulink assigns each input the name signalN, where N is the input port number.

  • Vector
The length of the vector specifies the number of inputs. Each element specifies the size of the corresponding input. A positive value specifies that the corresponding port can accept only vectors of that size. For example, [2 3] specifies two input ports of sizes 2 and 3, respectively. If an input signal width does not match the expected width, Simulink displays an error message. A value of -1 specifies that the corresponding port can accept scalars or vectors of any size.

  • Cell array
The length of the cell array specifies the number of inputs. The value of each cell specifies the size of the corresponding input. A scalar value N specifies a vector of size N. A value of -1 means that the corresponding port can accept scalar or vector signals of any size.

  • Signal name list
You can enter a list of signal names separated by commas. Simulink assigns each name to the corresponding port and signal. For example, if you enter position,velocity, the Mux block will have two inputs, named position and velocity.

Note: Simulink hides the name of a Mux block when you copy it from the Simulink block library to a model



  • Data Type Support
The Mux block accepts real or complex signals of any data type supported by Simulink, including fixed-point data types.

For a discussion on the data types supported by Simulink, see Data Types Supported by Simulink in the Simulink documentation.


  • Number of inputs
The number and size of inputs. You can enter a comma-separated list of signal names for this parameter field.


  • Display option
The appearance of the block in the model.




Thank You..

Electric machines play an important role in industry as well as our day to day life. They are used to generate electrical power in power plants and provide mechanical work in industries. They are also an indispensable part of our daily lives. Electric machines are very important pieces of equipment in our everyday lives. The DC machine is considered to be basic electric machines.

The aim of this final year project is to introduce students to the modeling of power components and to use computer simulation as a tool for conducting transient and control studies. Simulation can be very helpful in gaining insights to the dynamic behavior and interactions that are often not readily apparent from reading theory. Simulation is often chosen by engineers to study transient and control performance or to test conceptual designs.

MATLAB/SIMULINK is used because of the short learning curve that most students require to start using it, its wide distribution, and its general purpose of nature. This will demonstrate the advantages of using MATLAB for analyzing power system steady-state behavior and its capabilities for simulating transients in power systems and power electronics, including control system dynamic behavior