How to cast a vector to a bus in Simulink - simulink

Can one cast a vector (array of numbers) to a nonvirtual bus in Simulink? There's a bus to vector block but no vector to bus block. Is there a workaround?

I think you probably need to demux your vector and create the bus with a bus creator block. The purpose of the bus to vector block is "only to replace an implicit bus-to-vector conversion with an equivalent explicit conversion", see Correct Buses Used as Muxes in the documentation.

Related

Use Goto and From to Transfer Fcn block

I have made a block in Simulink that calculates some Aerodynamic coefficients.
I had like to use this coefficients in order to define the numerator and denominator of a transfer function.
Is there a way to link between the output from the coefficients block to the transfer function?
Thank you
No. The output of your aerodynamic block are signals. The numerator and denominator of the Transfer Function are parameters. You cannot use signals as parameters, or vice-versa.
What you can do is construct your own transfer function using an appropriate arrangement of Sum, Product and Integrator blocks, with the signals from your aerodynamics block being used (typically in conjunction with the Product blocks) to define the appropriate coefficients/gains.

How to implement math operations to bus signal MATLAB

I work in Simulink and have bus signal (now it consists of 11 signals, every signals is a vector). And I want to make some operations on this bus. It means to make the same operations at each of this 11 signals included in Bus.
I tried this way:
Just implement all my functions and operations at whole Bus. And some blocks (for example, Zero-Order Hold) works fine (it implements correctly to all it's signals). but next block - integrator - works fine (it really integrate all signals) but that crashes my Bus! It returns one vector. It has size equal to the sum of all Bus's signals.
I know I can use Bus Selector block to create 11 parallel signals and copy all my operations for each of them.
How to get Bus signal in more efficient way?
I made it this way (don't attach it like an answer, because Corey Z give the answer at the same time):
Is there any reason that you don't want to convert your bus to a vector to put it through the integrator?
Each vector signal in the bus will be appended to a 1-dimensional vector signal. The vector will come out of the integrator in the same dimensions that it went in and then can be turned back into a bus if need be using the bus creator tool under the signal routing toolbox.
On another note, it seems that you have some discrete time domain elements mixed into your block model along with your continuous-time integrator. If that gives you errors you may need to look into the Discrete-Time Integrator block.

Dymola modelica defining inputs for frequency analysis

Inputs in my multibody model are road unevennes as function of distance the model is working fine for time simulation but when I linearize the system, then i get error saying no inputs or outputs defined.As In the picture:
https://drive.google.com/file/d/0B8AmxzbhEQ_FczFuaDNhQjlqVUE/view?usp=sharing
I defined combitable as a input and parameter then I get the error:
Translation of TRyViertalMbsa:
Component type specifier CombiTimeTable is a block, this cannot be combined with the prefix input .
Component declared as CombiTimeTable combiTimeTable in Modelica.Blocks.Sources
Conflicting causality for combiTimeTable (input ) and its element y(output )
How can I define inputs and outputs for the state spac system?
I think the problem is that you are asking Dymola to linearize the model including the boundary values (the input time series). What you really want is to linearize the model only and let Dymola perturbate the inputs in order to determine the linear model. See example model:
https://drive.google.com/file/d/0B8ojPn4YxnI9a1FFa0ozY2tlT1U/view?usp=sharing
So, you must replace the two CombiTimeTable with two input connectors (Modelica.Blocks.Interfaces.RealInput).
Also, you would probably want to add one or more output connectors (Modelica.Blocks.Interfaces.RealInput) via mechanical sensors - angle, position or whatever.
Operating points
If you want to linearize your model around a specific operating point different from zero, you should add these (constant) values to the inputs and subtract them from your outputs. I don't know if there is a smarter way to handle the operating points in Dymola's linearization function.
Best regards
Rene Just Nielsen

Input/output port in Simulink

Is there a way to create an input/output port in Simulink (some workaround)? The port would be a bus and some signals are set from outside the block while some signals are set by the block. Here is an example:
Given the following bus:
Flow (scalar)
Composition (vector)
Enthalpy (scalar)
I would like Flow to be set from outside the block (there's a pump downstream which sets this value). Composition and Enthalpy are computed by the block.
My solution so far: Make Flow an input into the block and with direct feedthrough set it on the outport. I don't find this solution intuitive because from a graphical point of view the outflow becomes an input into the block (which is true from a math point of view - but I would like to make the Simulink diagram intuitive). I've seen in Modelica the possiblity to create input/output ports (RealPort) and the signal could be read or written by the block. I would need such a feature in Simulink.
It sounds like you need to use Simscape and SimHydraulics, which do excatly what Modelica does, but within Simulink. Each physical domain is represented with through and across variables, which are flow rate and pressure for the hydraulic domain. However, that's extra $$/££/€€ and a new modelling paradigm (you don't think in terms of inputs and outputs anymore)...
If you stay with Simulink blocks, there isn't much else you can do above what you've already done, although I assume you mean the flow is set on the input, not the output.

Simulink - Find computed index of multidimensional signal at specific time

I am trying to find which element(index) of a multidimensional signal is computed at a specific time in a Simulink model. Assume that there is a multidimensional input signal given to an add block together with a constant so Simulink calculates the sum with the constant for each element of the signal and gives the output as multidimensional signal. I want to know which index of the signal is computed at a time so I can do additional computation. How can I do that?
Do you want to do additional computation during simulation or after? In the latter case, you can save the multidimensional signal to the MATLAB Workspace as a "structure with time" variable. Then do your additional computations by finding the index of the time point of interest and the associated multidimensional data point. In the former case, you can probably a MATLAB function block with two inputs: the output of a clock block and the multidimensional signal. Then do your processing in there using MATLAB code.