Matlab Simulink generating no output - matlab

I am learning Matlab Simulink. Here is the basic simulation that I'm doing.
When I pressed Start Simulation I get these errors.
Then as suggested here I changed my settings to this.
But now when I am simulating, a warning sound beeps but no error message is showing in Matlab Command Window and I am not getting my output.
Where is the problem and how can I solve it??
I am using Matlab 7.10.0(R2010a).

You're not getting any output in the Command Prompt because you haven't specified any sinks to export the data to the Workspace and so workspace variables aren't created. You're only able to see the output in the Scope tool in Simulink but this data hasn't been exported to your workspace. In Simulink, there is a To Workspace block that you can use to pipe the sinusoidal data to the workspace. In the Sinks section of the Library Browser, choose the To Workspace block and connect the output of the Sine Wave black to this block... so:
To make things compatible, make sure you choose the option to output your data as an array format instead of time series... well I find that the array option is better. Open up the To Workspace block and change the output to Array:
When you do this and run the simulation, you should see a variable called simout in your workspace that captures this data and tout that measures the time steps of each output amplitude in your sine data:
You can then plot the data by doing just plot(tout, simout);
Minor Note
The "warning" beep happens because MATLAB is telling you that Simulink has finished the simulation. Nothing wrong is happening.

Related

simulink simulation workspace output values do not change after running simulation from GUI m-file

I am trying to create a matlab gui that simulates a DC/DC converter, and I have succeeded in exporting data from gui to simulink in order to change signal attributes. The problem is that, when I change the values using the gui, the output signals on scopes in simulink change but the signals that I import from the simulation stay the same unless i re-run the simulation from simulink. I am using the evalin function to export workspace data to my m-file. I tried waiting for the simulation to end in order to solve the problem but it didn't.
I hope the question was clear enough and thank you in advance for your help !
Thank you but the problem resided in the command i used to run the simulation and not waiting the proper amount of time in order for the simulation to finish.
To resolve this problem I used the following:
open_system('nameofmodel.mdl')
set_param('nameofmodel', 'SimulationCommand', 'start')
while ~strcmp(get_param ('nameofmodel','SimulationStatus'),'stopped')
pause(1e-99);
end

Save Simulink Scope Data to figure through matlab code

As a student I am currently working on a Matlab Simulink project. I am quite new to using Matlab/Simulink (few weeks).
I am using a load cell from which I gather data through UART and display it on a Matlab Simulink Scope. This works all fine. My next step was to implement and run a Matlab “.m” file with which I can open Simulink and start the simulation. The aim is to do a 24h Test cut into 1h “pieces” and to save the scope data to a figure each hour. So my Simulink simulation runs for 1h, stops and starts again, and so on. Through Matlab and a “for” loop I do the measures 24 times.
What I didn’t figure out:
Save the Simulink Scope Data to a figure through Matlab code, each time one increment in the loop ist done. I can get the figure from my Simulink Block but that’s not what I wanted (by that I mean that I literally get a screenshot from the Simulink Block; just to be clear).
for i=0:1:24
[…]
% Print to JEPG
fig = get_param('Simulink_Project','handle');
saveas(fig,sprintf('Figure%02d.jpeg',i ));
[…]
end
I hope that what I stated, was clear.
Thanks for your help.
Regards
hohmchri

How do I input variables into a Simulink model through MATLAB script (SimDriveline)

For my coursework project in MATLAB, I have decided to build a drive-line model within Simulink, using the SimDriveline toolbox. The idea is to get the user to input values for the various parameters that are associated with each part of the model, such as the engine or the transmission. I would like to able to write this in a MATLAB script, but I'm not sure how to assign the values that are input to the Simulink model. For instance, the stock sdl_vehicle example that comes with SimDriveline. I am aware of the sim() command, but I am still confused on how to use it properly.
Also at the end of the simulation, the program is supposed to display the graphs that are collected in the scope window. I know that in the window itself that the scope can be printed to a figure, but is it possible to print that scope to a figure through MATLAB script?
This is the first time I have ever used a program like MATLAB. I would appreciate any help I could get, many thanks in advance!
There is a simulink block called simin:
http://de.mathworks.com/help/simulink/slref/fromworkspace.html?searchHighlight=simin
I used it some days back and it worked quite well. You can use the block in your model and define some signals/varibles as input.
After that you may write a Matlab-Script with an input function to set all the previous defined input values.

Matlab: how to load data from a file while running a simulation using Simulink?

I would like to run a simulation using Simulink, and I would like to use data from a txt file. I have try using
x_ref_n0 = importdata('x_n_ref0.txt');
However, I am getting an error message:
The function 'importdata' is not supported for standalone code generation.
What can I do to solved this issue?
Are you trying to use importdata inside a MATLAB Function block? You should import the data in the MATLAB workspace and then use "From Workspace" or "Signal From Workspace" blocks to bring the data into simulink. If the data is too large to bring it into workspace, you should read the file a few lines at a time using fopen and then use textscan to parse the data. You can call these functions in many different ways. The stackoverflow question How can I call an m file in Simulink and put it to a block in my model? has many answers to call MATLAB code from Simulink.
If you are instead reading all the data from one file used in one time step from MATLAB Function block then you should declare importdata as extrinsic which will allow you to call a MATLAB function which does not support code generation. Using extrinsic will not support code generation using real time workshop. Simulation should work fine. See documentation for extrinsic at http://www.mathworks.com/help/fixedpoint/ref/coder.extrinsic.html

Why is my deployed MATLAB application unable to generate a new figure?

I have built a GUI with some text boxes and a pushbutton. When I execute the GUI from MATLAB, it produces the desired plot on a separate window. The plot is created by a function that is stored in the same directory and is called in the callback function of pushbutton.
When I package it with the .m file of the GUI as the main file, I get an exe. When this exe runs, it normally takes data from data source (sqlserver) but then does not give the plot in a separate window as within matlab (also not in the same GUI window). There is a sound and from the behaviour it seems that the plots appears and vanishes in a very short time. But this is my perception and may be wrong, maybe it is some error message that is suppressed.
What can I do to solve this?
You've run into the problem discussed here in this post
Once the code is finished evaluating it cleans up, including closing the window you created. One solution would be to pause your script right after plotting.
Here's a discussion of many functions that can be used to pause execution with a GUI.