-1

Is it possible to do something like this

     ----        -------
 --->|+ |------->| 1/s |-----o--------->
     | -|        |     |     |
     ----        -------     |
       /|\                   |
         -------------------- 

in a matlab ode m-file without the usage of simulink? And if it is possible how is it done? Maybe someone has got a code snippet of something that works this way?

cico
  • 23
  • 3

1 Answers1

2

Short answer: yes it's possible, but nobody's going to do it for you. The steps would be:

  1. Write down on paper the differential equation of the system
  2. Put it in a form dy/dt = f(t,y) and write it as a MATLAB function
  3. Solve the differential equation with one of the MATLAB ode solvers, e.g. ode45 (there are plenty of examples on the documentation page)

EDIT

As I said it doesn't get much easier than this...

enter image description here

am304
  • 13,758
  • 2
  • 22
  • 40
  • Ok. I know that but it seems I wasn't able to express. I know how to write the differential equation and also how to solve it with matlab. what I don't know is how to produce that feedback shown up there during the integration! I hope this makes my question clearer. – cico May 06 '14 at 09:12
  • That's basic maths. See http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed&section=SimulinkModeling for example. – am304 May 06 '14 at 09:17
  • The example you showed me are using simulink. I don't want to use simulink. I just want to use matlab and call the solver directly with a function I wrote. The only thing I need is that behaviour shown up there in my funtion ... that is the question. I'm sorry but I am not a native speaker. – cico May 06 '14 at 10:18
  • The example I gave you does use Simulink, but more to the point shows the relationship between the mathematical equations and the block diagram (including the feedback loop). Use it to derive the equations of your block diagram, it's really not that hard. – am304 May 06 '14 at 10:55