matlab 2016a simulink graph legend - matlab

I have a question about matlab simulink:
Notice just Matlab 2016a simulink because of in old version i can do it but in 2016 version i can't change or set new legend to scope graphs.
help me to do it please.
Thank you

I have 2016b, so I'm not sure I can solve your problem at 100%, but I can give you some examples how to set current names for legend.
First of all turn on the legend property: Scope\View\Legend
Now we can see legend but it has default names. Lets change it!
First method - I can just double left click on it and change it's names. But it is not really good - I can put any signal name even if there is no such names in the simulink model.
We can assign any names to signals in the model:
Another method is to give current names to your blocks - scope shows that names by default. It is informative (so and previous method) because we can easily see where this signal comes from.
Maybe it is what you want.

Related

MATLAB - In FindPeaks, how is 'MinPeakProminence' different from 'Threshold'?

I have written a code in Matlab R2017a, where to detect peaks, I used MinPeakProminence. Now I need to shift the code to Matlab 2014, where MinPeakProminence doesn't exist, while theres in another option called 'Threshold'. But for some reason, it doesn't give out the same results as MinPeakProminence.
How are they both different? What should I be doing to get the same result of MinPeakProminence in Matlab 2014?

Searching constant value through all Simulink blocks

I have a big Simulink model with a lot of User-Defined MATLAB functions. And I went wrong way - I used some local data in many blocks. For example - water density. I just used 1000 in formulas or some local variables like this: wat_den = 1000; in a lot of different functions (MATLAB function blocks).
And now I got the problem - I tried to simulate my model for another liquid (so, another density). Now I understand, that I have to use all this variables in another way - I create table of all constant and route them to functions directly.
And my question - is it possible to find variable or numeric value in all functions? because Ctrl+F can't finds inside of any user-defined functions (it can find only signal's names, port names, etc) and I forced to open every block and check it's content.
you can easily do this by doing CTRL + SHIFT + F
It will open up a gui and you can write in the field: *Find Files containing text: * the name of your variable.
This will search all the instances of that variable throughout your Current Folder (you can even change where to search).
Note: You can change the extension of the file you want to search.
I hope this helps. I am using Matlab r2015b

How to create the approximately equal mark in MATLAB

I want to create the approximately equal mark in the legend of the MATLAB. And it will show correctly, but when I try to export the plot by saveas (gca,'1.eps','psc2'). Then in the file, the approximately equal mark will be error code.
MATLAB legend(), title(), xlabel() and ylabel() functions interpret tex commands by default. A quick search suggests \approx or \cong as possible symbols to try. If it works, could you update your question with before and after examples?
This is what I have in mind
figure
title('Pi \approx 3.14')
or
title('Pi \cong 3.14')
See here for more details of MATLAB tex interpretation.

Getting the solver type and step size (for fixed step solvers)

we are trying to integrate a simulation model into Simulink as a block. We have a custom continuous block which loads an m file that contains the functions Derivatives, Outputs etc.
My question is: is there a way to find out which solver is used currently and with which parameters? Our model won't be able to support variable time solvers and I would like to give a warning. Similarly, the model requires the fixed step time for initialization.
Thanks in advance.
You can get the current solver name using
get_param('modelName', 'SolverName');
Some of the other common solver parameters are
AbsTol
FixedStep
InitialStep
ZcThreshold
ExtrapolationOrder
MaxStep
MinStep
RelTol
SolverMode
You can find other parameters you may wish to query by opening the .mdl file in your favorite text editor and digging through it.
If I'm understanding your use case correctly, you are trying to determine the type of solver (and other solver params) for the top-level simulink system containing your block.
I think the following should give you what you want:
get_param(bdroot, 'SolverType'); % //Returns 'Variable-step' or 'Fixed-step'
get_param(bdroot, 'FixedStep'); % //Returns the fixed step size
Notice that for purposes of generality/reusability, this uses bdroot to identify the top-level system (rather than explicitly specifying the name of this system).
If you want to find out more about other model parameters that you can get/set, I would check out this doc.
Additionally, I'm interested to know why it is that your model doesn't support a variable-step solver?

Setting the value of an array control of a Labview VI through ActiveX (with Matlab)

I have a Labview VI that I intend to run from Matlab through ActiveX. It has one argument (that is, one Labview control), which is of type 1D numeric array.
The method used to call the VI from Matlab through ActiveX is detailed in a previous post.
I am trying to set the value of this array control in Matlab before running the VI (that is, Matlab will pass an argument to the VI and then run it; no action is to be performed manually through the Labview interface).
Getting the value through the GetControlValue method works fine (I get a nice Matlab array). However, when I try to set the value of this same control with SetControlValue using the value returned by GetControlValue, the value of the control becomes empty (as evident from the value Empty matrix: 1-by-0 obtained by Matlab after using GetControlValue again, and in Labview where the values of the control become grayed-out).
The same procedure works perfectly when the control is a single numeric value.
What is going wrong here exactly ?
See the screen capture below:
You can compile the VI to a DLL and call your function that way. This abstracts away LabVIEW's typesystem and its COM runtime.
Can you provide more detail about the problem you are trying to solve?
(Source: 0utlaw on the NI forum).
A useful workaround to this problem is to use a Matrix control in Labview.
Matlab can then pass usual arrays, and Labview maps these Matlab arrays to the matrix. Works as expected with 2D arrays as well.