-2

I have created a FIG gui which has options to start or open a new project, open a custom library, simulate, plot graphs etc. On clicking the start new project option a new simulink window will open.I have made a custom library which has blocks or elements that I have created on my own, each having associated parameters, shown below:

enter image description here

Then the user can drag and drop these blocks as required to the simulink window and make a single line diagram by interconnecting these blocks. Then the user can click on each block and enter the parameter values. Now when the user clicks the 'simulate' option in the FIG gui, simulation has to be done according to the equations that I have. How do i access the simulink block parameters that the user has entered and how do i program the equations (M code?, matlab functions?) when i write the matlab functions how do I specify the input arguments since they are the values that the user will provide in the simulink window?? I tried searching a lot but not getting a clear idea.The results are focussed either entirely on GUI creation or I would say leaving very vague ideas of what exactly has to be done. It would be of great help if someone could list down the steps for a beginners perspective. Thanks in advance

am304
  • 13,758
  • 2
  • 22
  • 40
  • 1
    If you have a Simulink model, you should simulate that model with [`sim`](http://uk.mathworks.com/help/simulink/slref/sim.html), not try to re-create the equations of the Simulink model in MATLAB code. – am304 Feb 11 '15 at 08:37
  • I am just using the simulink environment as a platform on which I can draw the single line diagram of my system and perform simulations. The libraries is totally customized wherein the block parameters are defined by me. hence if i use these blocks and interconnect them the simulation should be based on the equations that I have supporting the parameters. – Norina Samson Feb 11 '15 at 09:29
  • For eg. suppose Block 1 has params a,b,c and Block2 has parms x,y,z and i have few equations relating all these params like w = a/x; etc , I drag and drop these two blocks to my simulink workspace and interconnect them, and when i click on RunSimulation option (which i have provided in a GUI as mentioned int he 1st question), the compiler must identify the file containing these equations and plot graphs in the GUI. Hence my doubt is how to specify the block parameters(a,b,c,x,y,z) in my function definition in the Mfile – Norina Samson Feb 11 '15 at 09:29
  • Sorry I don't understand. You connect the blocks, parameterise them and run the model, that's all there is to it, the equations **are** the blocks, no need to write any. Maybe you can post a link to a screenshot of the GUI & model, with some blocks and parameters. – am304 Feb 11 '15 at 09:45
  • http://tinypic.com/view.php?pic=2csjkar&s=8#.VNuI4PmUe2Y This shows the library in which I have created some elements. I am experiencing some problem with matlab now hence could not get a screenshot of the model. But then any of these blocks will be dragged and dropped to the work console and then I have created a gui which has the option to Open/New/OpenLibrary and Simulate. Hence when i click on simulate the equations which has to link the blocks have to be called. I can implement the equations in mfile...but how do i access the simulink block params the user will give during modeling – Norina Samson Feb 11 '15 at 16:53

1 Answers1

1

Your question is still not clear, but it sounds like you are trying to access/change the block parameters of the model based on what the user enters in the GUI (correct me if I'm wrong). The functions to do this are get_param (to read the block parameters) and set_param (to change them).

I'll say it once again: you do not need to implement the equations in a MATLAB file, that is exactly what the Simulink model is doing. What you need to do, after setting the block parameters to the correct value and connecting them correctly, is run the constructed model using sim.

am304
  • 13,758
  • 2
  • 22
  • 40
  • I appreciate the response. But the problem is the blocks shown in the library (as shown in the screenshot) are created by me. They are not predefined in the MATLAB library. Hence the parameters entered into the blocks will be unknown to MATLAB compiler as well. Only I know the equations that relate the parameters in the blocks. Hence when i run the model using sim the compiler will look for a file which contains the parameters/relating the parameters. That has to be created by me, is it not? – Norina Samson Feb 13 '15 at 02:23
  • Yes, I can see the blocks are custom-made, but surely underneath the mask you have a mathematical representation made of standard blocks combined together, it's not just an empty shell? The whole point of Simulink is not to have to write equations. It is a modelling and simulation tool, not a simple drawing tool. When you connect the blocks together, you create the mathematical equations of the model and once you have the correct parameters, you have your mathematical model ready. When you simulate the model with `sim`, it will work out all the equations of the model and attempt to solve them. – am304 Feb 13 '15 at 07:44