simulink

Calling fmincon from Simulink

有些话、适合烂在心里 提交于 2019-12-24 09:25:41
问题 I am trying to implement a particular type of model predictive control in the Simulink-Matlab framework. To do so, my plan was to have the dynamic model in Simulink call an external Matlab S-function which in turns runs an optimization that calls a different Simulink file. Hence, the program flow would be as follows: Simulink -> Matlab ( fmincon or quadprog ) -> Simulink. As you can see, the Matlab S-function would call either fmincon or quadprog , but I would like to use fmincon for my

Matlab: Linearizing Simulink model and getting linearized transfer function?

谁都会走 提交于 2019-12-24 03:43:36
问题 I want to determine the linearized transfer function from a non-linear system made in Simulink. I can see that it should be possible to use the linmod function in Matlab but when I try this [num,den]=linmod('sys') I'm not getting the numerator and denominator but instead the state space matrix etc. Can anyone help? 回答1: Try the function balred instead: documentation rsys = balred(sys,ORDERS) computes a reduced-order approximation rsys of the LTI model sys . The desired order (number of states

Solving ODE with Simulink in Matlab

半城伤御伤魂 提交于 2019-12-24 03:07:56
问题 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 = y2 y2= e^(3*x) + y' + 2y Using ODE solver. If someone can help me to solve this using a Simulink Model I would appreciate it. I know how to solve it in Matlab using ODE solvers as ode23 and ode23s but I don't know how to do it using a Simulink Model. Thanks in advance

Matlab and mechanics (mostly physics)

柔情痞子 提交于 2019-12-24 03:04:26
问题 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, w2 = dphi2/dt, phi12 = phi1 - phi2 w12 = w1 - w2 Td(w12) = c12 * w12 Ts(phi12) = ks * phi12 c12 and ks are some coefficients • dphi12/dt = w12 • dw12/dt = T1/J1 - T2/J2 - Td(w12)/Jeq - Ts(phi12)/Jeq ccr = 2*Jeq*wn

Delete all blocks except specified ones in simulink model

丶灬走出姿态 提交于 2019-12-24 02:44:36
问题 Is there any equivalent command to the clearvars -except keepVariables which can be used in a simulink model to delete all blocks, ports and lines, except specified ones? 回答1: This is one general way to do it, explained used the in-built example vdp : simulink; name = 'vdp'; %// open system, pause just for displaying purposes open_system(name); % pause(3) %// find system, specify blocks to keep allblocks = find_system(name); ToKeep = {'Out1';'Out2'}; %// add systemname to strings ToKeep =

Simulink - programmatically specifying external inputs

与世无争的帅哥 提交于 2019-12-24 02:05:11
问题 I would like to adjust some Simulink parameters programmatically, namely specifying external inputs and initial state. The Mathworks' help document on Data Import/Export shows how to do so both visually and programmatically. Apparently for external inputs, I need to specify LoadExternalInputs to 'on' ; I would like to override the default external input via ExternalInput to [myTimeVar, myInputVar] , as documented in that link. Trying to run the command sim('mySim', 'LoadExternalInputs', 'on',

Save Matlab Simulink Model as PDF with tight bounding box

久未见 提交于 2019-12-23 18:48:56
问题 Given a Simulink block diagram (model), I would like to produce a 'Screenshot' to be used later in a LaTeX document. I want this screenshot to be PDF (vector graphic, -> pdflatex) with a tight bounding box, by that I mean no unneccessary white space around the diagram. I have searched the net, searched stackexchange, searched the matlab doc. But no success so far. Some notes: For figures, there are solutions to this question. I have a Simulink block diagram, it's different (see below). I am

How to create a counter in simulink

旧巷老猫 提交于 2019-12-23 18:29:42
问题 I would like to count how many times my signal goes to zero. For example having an impulse signal as input I want a variable which counts how many times the impulse goes to zero. I´m becoming crazy thinking of something....can anybody help me? Thanks 回答1: figure 1 is a pulse counter model and figure 2 is scope output which shows for 5 input pulses we get counter output as 5 回答2: There is a similar question here that might help. There are loads of ways to implement a counter, but a good way I

基于FPGA的图像处理(一)--System Generator介绍

拈花ヽ惹草 提交于 2019-12-23 09:58:53
计算机视觉系统通常需要进行大量的信息处理才能够得到所需要的信息。目前主要有CPU、GPU、ASIC、DSP、FPGA等计算平台。 常用的计算机视觉系统通过通用计算机进行视觉信息处理,但是,由于CPU的计算能力有限,对于一些计算复杂度很高的视觉算法,其处理速度常常难以满足系统的实时性需要。 GPU具有高度的并行计算能力,可以较好地解决计算速度的问题,然而,基于GPU的计算机视觉系统存在着功耗较高、体积较大的缺点,难以满足依靠自身所带电池供电并长时间工作的服务机器人等应用系统的需要。 利用专用集成电路ASIC实现视觉处理算法,可以解决视觉系统性能和体积、功耗之间的矛盾,是高性能嵌入式视觉系统的一种有效的解决方案。然而,ASIC开发周期长、修改不方便,通用性较差。 FPGA可以通过编程方便地修改其内部的逻辑功能,从而实现高速的硬件计算和并行运算,是高性能嵌入式视觉系统的一种更加方便的解决方案。基于FPGA的嵌入式视觉系统的功耗远远低于基于CPU和GPU的视觉系统,FPGA的功耗通常不到1W,而高性能CPU和GPU的功耗通常都在100W以上。随着技术的不断进步,FPGA的集成度越来越高,可以实现的设计规模越来越大,而功耗则越来越低。因此,基于FPGA的嵌入式视觉系统将是计算机视觉系统的重要发展方向。 使用FPGA进行图像处理时,既要对赢家有很深的了解,同时又需要对图像处理的算法很熟悉

Editing the Code of a “MATLAB Function” Block in Simulink Programmatically

半世苍凉 提交于 2019-12-22 22:21:24
问题 I'd like to create a simple Simulink model containing a "MATLAB Function" block programmatically -- i.e. using Matlab code. Thanks to this guide, I've managed to create a new model containing the block: open_system(new_system('my_system')) add_block('simulink/User-Defined Functions/MATLAB Function', 'my_system/my_func') Usually, in order to edit the "MATLAB Function" block's code, one has to "open" the block by double-clicking on it then entering the new code. However, I would like to set