How to make output in matrix from 2 input parameters?

3 visualizaciones (últimos 30 días)
Michal Schreiner
Michal Schreiner el 25 de Feb. de 2022
Respondida: Shlok el 17 de Oct. de 2024
Hello!
I would liek to ask for your best tip how to proceed with this problem.
I need to set some block in simulink (probably just some basic blocks) to solve this:
There are two inputs signals, for example : first from 0-30 (specified by these 2 points and interpolated), second from 70-90.
Based on this two points i need output in matrix 8x3. So it means that for this combination of inputs i need 8x3 matrix on the output.
I solved similar problem (3 inputs, 1 output) with 3D LookUpTable, but here is different situation - on output i need matrix and not just one single value.
Do you have any ideas how to solve this problem? Maybe i can make several tables and have output as matrix 8x1 and repeat this for 3 times?
Thank you so much for your help and inspiration!

Respuestas (1)

Shlok
Shlok el 17 de Oct. de 2024
Hi Michal,
I understand that you want to obtain an 8x3 matrix as the output of the modal instead of a single value. To achieve this, I suggest you using the MATLAB FunctionBlock in Simulink:
This block allows you to take inputs and process them using MATLAB code, making it possible to output a matrix directly. Below is an example of how you can implement this.
In the MATLAB FunctionBlock, I’ve written the following sample code to process two inputs and output an 8x3 matrix:
function output = GenerateMatrix(input1, input2)
output = zeros(8, 3);
for i = 1:8
for j = 1:3
output(i, j) = input1 * i + input2 * j;
end
end
end
This code generates an 8x3 matrix based on the two input signals.
Note that I’ve assumed a sample example here and built the model accordingly. For your specific case, you may need to modify the logic and include additional blocks in your Simulink model as needed.
To know more about implementing MATLAB functions using block, you can refer to the following documentation link:
Hope this helps.

Categorías

Más información sobre Array and Matrix Mathematics en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by