Problem with number of inputs and outputs

21 visualizaciones (últimos 30 días)
BAPTISTE PLASENZOTTI
BAPTISTE PLASENZOTTI el 5 de Jul. de 2023
Comentada: BAPTISTE PLASENZOTTI el 10 de Jul. de 2023
Hi everyone, I have just a little question about inputs and output.
First of all, the thing that I want to do is to put as input of an generic engine a variable that change for every second of the simulation (variable from Matlab workspace).
So I put a "From workspace" block and it has 2395 outputs, so of course it cannot connect to a simulink - PS converter that have only one input port.
That's why I'm asking how can I do this.
Thanks in advance for the reply !

Respuesta aceptada

Sara Nadeau
Sara Nadeau el 6 de Jul. de 2023
What is the type and format of your input data? What type of output do you expect from the From Workspace block?
The From Workspace block supports several formats of input data. In general, creating a timeseries object works for most workflows and provides consistency with the format for most logged data as well.
Here is the reference page for the From Workspace block: https://www.mathworks.com/help/simulink/slref/fromworkspace.html
And here is an example that shows code examples for getting numeric vectors into each supported format: https://www.mathworks.com/help/simulink/ug/load-data-using-the-from-workspace-block.html
I hope these doc links are helpful. If you have more questions or could provide more information about exactly how you configured the block and formatted the data in a way that resulted in this form of output, I might be able to give a more specific answer.
  3 comentarios
Sara Nadeau
Sara Nadeau el 7 de Jul. de 2023
Editada: Sara Nadeau el 7 de Jul. de 2023
So you have said that the output has 2395 elements, and you don't think that is correct.
What are the dimensions of the output with 2395 elements? 1x2395? Something else?
I am less familiar with the Signal Builder block so considering the From Workspace block again - how did you specify the Data parameter that resulted in the output with 2395 elements?
Based on the description about wanting the output at 34s to be the 34 point in the list, I can describe a way to get this out of the From Workspace block, but I can't promise it will be exactly what you need.
When you use the structure without time format, you can specify input values for the From Workspace block to load each time it executes without specifying time values that correspond to each input value. To associate the value with simulation time, you then specify the sample time for the From Workspace block and disable linear interpolation. You said that you want the 34th value in the list to be the output for 34 seconds, which would imply a sample time of 1 second.
This code would create the variable simin using the structure without time format. The data just counts from 0 to 34. The call to set_param sets the sample time for the From Workspace block to 1 second and disables interpolation.
data = 0:34;
simin.signals.values = data;
simin.signals.dimensions = 1;
simin.time = [];
set_param("mymodel/From Workspace","SampleTime","1","Interpolate","off")
In simulation, this From Workspace block loads one value from the specified input data every 1 second of simulation time.
This page of the documentation shows another example that includes code and a model to see how this works: https://www.mathworks.com/help/simulink/ug/specify-how-to-load-simulation-input-data.html#mw_6c72ce30-a717-48eb-989c-cbb1d0e154b4
BAPTISTE PLASENZOTTI
BAPTISTE PLASENZOTTI el 10 de Jul. de 2023
These new parameters seem to work !
In the meantime I tried with a "signal builder" block, and it seems to give the same result. Now my new challenge is to understand how the "generic engine" block works in order to be able to carry out my long project.
Thanks a lot !

Iniciar sesión para comentar.

Más respuestas (1)

Aniketh
Aniketh el 5 de Jul. de 2023
To connect multiple outputs from a "From Workspace" block to a single input port of a Simulink block, you can use a "Bus Creator" block. The "Bus Creator" block allows you to combine multiple signals into a bus signal, which can then be connected to a single input port.
Here's how you can connect multiple outputs from the "From Workspace" block to a single input port using a "Bus Creator" block:
  1. Place a "From Workspace" block in your Simulink model.
  2. Specify the variable name and the sample time for the "From Workspace" block to retrieve the data.
  3. Right-click on the "From Workspace" block and select "Outputs > Add Output". Repeat this step for each output you want to have.
  4. Place a "Bus Creator" block in your Simulink model. You can find it in the "Simulink/Signal Routing" library.
  5. Open the "Bus Creator" block by double-clicking on it.
  6. In the "Bus Creator" dialog box, click on the "+" button to add a new bus element for each output from the "From Workspace" block.
  7. Give each bus element a name and specify its data type and dimensions to match the corresponding output from the "From Workspace" block.
  8. Connect the outputs of the "From Workspace" block to the corresponding bus elements in the "Bus Creator" block.
  9. Connect the output of the "Bus Creator" block to the input port of the Simulink block that requires the multiple inputs.
By following these steps, you can combine the multiple outputs from the "From Workspace" block into a bus signal using the "Bus Creator" block. This bus signal can then be connected to a single input port in your Simulink model.
  1 comentario
BAPTISTE PLASENZOTTI
BAPTISTE PLASENZOTTI el 6 de Jul. de 2023
Editada: BAPTISTE PLASENZOTTI el 6 de Jul. de 2023
Hello ! Thank for your answer !
I have expressed myself badly in the previous message, this block have one output but with 2395 elements. So I don't think that the bus creator is the right choice. (but that's my bad, my english still needs more practice, sorry for the misunderstanding)
The thing that I want to do is for exemple at 34 second, the output of the "From Workspace" block is the 34 in the list. Like this my engine at 34 second get the data number 34 that I want it to take.

Iniciar sesión para comentar.

Categorías

Más información sobre Troubleshooting en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by