Documentation Center

  • Trial Software
  • Product Updates

Contents

db_0117: Simulink patterns for vector signals

ID: Title

db_0117: Simulink® patterns for vector signals

Priority

Strongly recommended

Scope

MAAB

MATLAB Versions

All

Prerequisites

None

Description

Simulink is a vectorizable modeling language allowing for the direct processing of vector data. Use the following patterns for vector signals within a Simulink model:

Equivalent FunctionalitySimulink Pattern

Vector loop

for (i=0; 
i<input_vector_size; i++) 
{ 
output_vector(i) = 
input_vector(i) * 
tunable_parameter_value; 
}

Vector loop

for (i=0; 
i<input_vector_size; i++) 
{  
output_vector(i) = 
input_vector(i) * 
tunable_parameter_vector(i); 
}

Vector loop

output_signal = 1; 
for (i=0; 
i<input_vector_size; i++) 
{ 
output_signal = 
output_signal * 
input_vector(i); 
} 

Vector loop

output_signal = 1;  
for (i=0; 
i<input_vector_size; i++) 
{ 
output_signal = 
output_signal / 
input_vector(i); 
} 

Vector loop

for (i=0; 
i<input_vector_size; i++) 
{
output_vector(i) = 
input_vector(i) + 
tunable_parameter_value; 
}

Vector loop

for (i=0; 
i<input_vector_size; i++) 
{  
output_vector(i) = 
input_vector(i) + 
tunable_parameter_vector(i);  
} 

Vector loop:

output_signal = 0;  
for (i=0; 
i<input_vector_size; i++) 
{ 
output_signal = 
output_signal + 
input_vector(i);  
} 

Vector loop:

output_signal = 0;  
for (i=0; 
i<input_vector_size; i++) 
{ 
output_signal = 
output_signal - 
input_vector(i);  
} 

Minimum or maximum of a signal or a vector over time:

Change event of a signal or a vector:

Rationale

  • Readability

  • Verification and Validation

  • Code Generation

Last Changed

V2.2

Model Advisor Check

Not applicable

Was this topic helpful?