I am trying to make a library of functions that will allow me to parameterize filters and other function. In simulink standard blocks, I am only able to set a sampling time prior, rather than take an input. Is there any ideas on how I can create this? My first...

I'm trying to "translate" a Simulink model (built to solve a second order ODE and shown in the picture below) into python. inW and inT are vectors of dimensions [1601x2], gains MFW and MFT have dimension [2x1] and gains MC and MK have dimension [2x2]. All initial conditions have been...

Resume form part 1 Basic scheme representing the system: We assume that coupling of the two shafts is done with a clutch Equations: • J1*dw1/dt + Td(w12)+Ts(phi12) = T1; • J2*dw2/dt - Td(w12) -Ts(phi12) = T2; where w1 = dphi1/dt, w2 = dphi2/dt, phi12 = phi1 - phi2 w12 =...

For my SIMULINK model I need to generate a signal that takes the values 1 or 0. To generate it I need to draw a number from a an exponential distribution and use this number as the time the signal stays in 0. Once this time has passed, I have...

I have a Simulink diagram 'abc.slx' developed by a colleague. When I open the diagram, I get a warning: Workspace for block diagram 'abc.slx' was not loaded because an error occurred while loading the MAT-file 'C:\Users\roger\Dropbox\etc\abc.mat' Cannot reload workspace from non-existing data source file: 'C:\Users\roger\Dropbox\etc\abc.mat' It's not surprising it can't...

I need help about a simulink function: I have n entities, in this example only 2. Attribute entity 1: ID = 1 , VALORE = 5 Attribute entity 2: ID = 2 , VALORE = 3 I need to call a function only one time instead of looping and if...

I have a vector data (an array variable for example float32 mydata[5];). for transmitting a single primitve/basic data in a bus its pretty simple. inside_data=Simulink.BusElement; inside_data.Name='somename'; inside_data.SampleTime = -1; inside_data.datatype='single'; this element can be put inside a using Bus=Simulink.Bus; Bus.Elements=inside_data; But this works when the input is a primitive. But...

Looks like multiple people are having trouble with this, none of the workarounds worked for me though. I am using Matlab 2014b with Simulink 8.4. I am solving a DAE system that describes a turbocharged engine. The system consists of 4 equations, 2 of them are DAEs, 2 are ODEs....

In simulink, when you clone a subsystem, after a while, you need to update them. The problem is that when you update a subsystem, the cloned one is not updated as well. Is there any way to synchronize the cloned subsystem in a way that when you change each of...

For debugging, I have some plots of vectors in an embedded matlab function in Simulink. Up to Matlab R2013b, everything works just fine with the following minimum example code: function fcn %#minimum example for plot within for-loop of embedded matlab function coder.extrinsic('delete'); coder.extrinsic('quiver'); coder.extrinsic('gobjects'); numSteps=4; persistent hFig; persistent hVector; if...

I am running a simulink model in external simulation mode and am having the following problem: When I stop the simulation and get the data from the scope, it never saves more than the last 5,000 data points. I have tried unchecking "Limit data points to last:" checkbox, but that...

I'm working with an open source Matlab toolbox which, according to its creators, is compatible for versions of Matlab over 7.6, i.e., R2008a. I tried to run it in R2011b and it threw the exception: Undefined variable "Simulink" or class "Simulink.Mask.create" Since: 1- Simulink is installed and functional in this...

I have a subsystem I am trying to make, and within this subsystem is a discrete filter block. I am trying to place a mask over the subsystem, and have it so the dialog will set the sampling rate of the discrete filter block. Is this possible and how? The...

I'm looking to improve the delay estimation portion of a Simulink model. The input is an estimated impulse response for the system. I want the index of the first sample of the impulse response where the sum of the absolute values of it and the previous elements exceeeds a certain...

Hello I would like to know how to save the previous value of an output variable in a matlab function. function y = fcn(x,d,yp) yp=0; %here I want to initialize this value just at the start of simulation if (x-yp<=d) y=x; else y=yp + d; end yp=y; % here i...

I have a system of ODEs as follows: dx1/dt = (x1,x2,x3) dx2/dt = (x1,x2,x3) dx3/dt = (x1,x2,x3) The initial conditions are x1=x2=x3=0 @ t=0 and the constraints are dx1/dt = 0, dx2/dt = 0, dx3/dt = 0 for x1 = 1, x2 = 1, x3 = 1 respectively. Once x1,...

How can I put values into a matrix in simulink? For example, if I sampled a sine wave every 0.5s, and put that value into a fixed size matrix of size N. After the matrix is full, it would overwrite the oldest values.

how to import a bitsream form binary vector from workspace into simulink.Actually I have found that I can use simin block or In block but my binary vector is independant of time. I tried to use Const block and it works but afer that when I wanted to put my...

I am trying to solve a mechanics problem regarding momentum of two shafts. I have never had a class an mechanics before, so i don't know how to approach this problem. Given: equations: • J1*dw1/dt + Td(w12)+Ts(phi12) = T1; • J2*dw2/dt - Td(w12) -Ts(phi12) = T2; where w1 = dphi1/dt,...

I need to solve this ODE using Simulink and I don't know how to make it. I only know how to do it using ODE solvers. y'' - y' - 2y = e^(3x) y(0)=1, y'(0)=2. I rewrote the equation obtaining an ODEs: y' = f(x,y) y(x0) = y0 y'1 =...

I tried my whole Simulink model with the configuration which are mentioned in the answer of my previous question by am304.But, an error concerning the fixed step size appears to me. Unfortunately, I couldn’t understand what it means: The computed fixed step size (2.195764022074938e-011) is 1000000 times smaller than all...

Here is my problem: We would like to use our different Simulink models within a script in a much faster way than having to open the Simulink environment (our MATLAB script using Simulink is launched many time). For that purpose, I want to transform the Simulink model into a C...

I'm trying to Include some Libraries, like metis in the custom code library section in Simulink. Do you know what type of libraries Simulink excepts? Must they have the ending .a, .o, .dll or lib? And can I include them into my custom c code with #include <metis.h>?

I would like to make a discrete filter, where the sampling rate can be controlled by an input. I am trying to understand how the discrete filter block looks, "under its own mask." Is there anyway to retrieve the code behind this block so it can be modified for my...

I want to import several arrays of data into Simulink so that I can cycle through each of those arrays, operating on one column at a time, and choosing a different array at random intervals. (So let's say I start cycling through the columns of array 1 for 1 second,...

I want to be able to externally have inputs for the lower passband edge frequency and higher passband edge frequencies for the butterworth filter block in the simulink signal processing toolbox in matlab. How can I achieve this. Currently you'll have to click the block to specify these frequencies and...

I am trying to find transfer function for some input data and output data using the code Temperature = [zeros(1,153) 300*ones(1,47)]; out_temp = [zeros(1,147) ScopeData4.signals(1).values']; N = 1; tfdata_tem = iddata(out_temp,Temperature,0.001); sys = tfest(tfdata_tem,N); but in the end I get the following error despite the fact that i have increased...

I have written a S-Function in MATLAB. Now I want to pass a Matrix into the input via the 'simin' Source. I have initialized the time of the simin variable with simin.time = 0 and the values are stored in a dynamically sized matrix. So for example simin.signals.values = ones(4)....

I am working on a simple System Object in Matlab/Simulink. It looks like this : classdef realtime_header_detectorSO < matlab.System & matlab.system.mixin.Propagates % correlateHeader % % This template includes the minimum set of functions required % to define a System object with discrete state. properties Header %nrOfBitsInPreviousStep=0; s=100; d=zeros(1,s); end properties...

Matlab beginner here and I'm stuck on some problem and neither Matlab documentation nor other posts here could help me. I'm working on a Level-2 Matlab S-Function that receives a sensor signal via USB (Gyroscope, Magnetometer and Accelerator signals) and I have to analyze this data every 200ms for more...

I'm writing a simulink device driver block for Arduino Due with the Matlab Function Approach as explained in the Simulink Device Driver guide. When I want to pass a double from the C++ code to the matlab function code with coder.ceval() I get a wrong number. Here is an example:...

I am new to Matlab and I need to perform a simple task. I have an input function u(t)=2t-1 and an output function y(t)=(-4/45)e^3t+ (1/5)e^(-2t)-1/3t-1/9 I have to find the corresponding behavior model, defined via a transfer function and then simulate the behavior model in Matlab/Simulink. I am not sure...