Simulink unit conversion - simulink

I need a simply rad/s (my default output signal) to RPM in Simulink and I want it to show the conversion in a display box.
I tried with Unit Conversion block but I cannot understand where I can give him the conversion
RPM = (rad/s)*60/2pi
Is it possible to write a simple matlab line inside the display box to show the new number instead of call a matlab function inside simulink?
Thank you
Edit: I found in the Aerospace blocket the angular conversion block. It's perfect. In any case I'm interested in a solution without using these blocks (if I wouldn't have the aerospace toolbox installed)

Related

MATLAB - EEGLAB: surpress GUI for pop_eegfiltnew()

I am working on some scripts for which I use several functions from the EEGLAB package for matlab. Most of these functions make it possible to surpress the GUI from showing, for example using f( ... 'gui','off'), or by using a different version of the same function. However, I can not figure out how to do this for the function pop_eegfiltnew(). Two similar functions are eegfilt(), which seems to be an outdated version of the function, and firfilt() however, pop_eegfiltnew() has more arguments than these other two, so they are certainly not the same in functional terms.
Anyone knows how to get around this?
If you supply enough arguments to pop_eegfiltnew it does not pop up a GUI.
For example if you wanted to filter your signal 1 Hz highpass you would:
EEG = pop_eegfiltnew(EEG, 1, 0);
This is because the first argument of pop_eegfilt is EEG structure, the second is locutoff (lower edge of the passband) and the third is hicutoff (higher edge of the passband).

Control modelica model in dymola, using matlab and command importInitial(dsName="dsfinal.txt")

I want to control from matlab a modelica model implemented in Dymola. At each x-seconds, matlab reads the states values and it calculates the new parameters values of the model and calls dymola to simulate the model with these new parameters values.
I try to initialize the states using the final values of the previous simulation using importInitial(dsName="dsfinal"); and then simulating.
This works if I give the command straight in the simulation log but it doesn't work when I call it from matlab, eventhought exactly the same command appear in the dymola simulation log.
Could any one help?
Thx!
The problem was due to the change of the parameters values.
Using following code solved it:
1) use simulateModel() with all simulation parameters you want for the first simulation
2) use importInitial('dsfinal.txt') to import the final state values
3) use modelName.parameterName = newValue to change parameter value
4) use simulate() to simulate further with the same settings as first simulation.
See also: http://www.claytex.com/how-to-restart-a-simulation/

Matlab Simulink function

I am building a reduced order observer in MATLAB. The matrices are calculated using functions/script files outside matlab and simulink function blocks are using these functions to calculate values.
The problem is that some commands like 'acker', 'place' etc which used to work on command window/function/script files are not working in simulink function block and showing errors.
I tried using simin block to take these matrices from workspace but it is also showing errors which I can't understand.
Thanks for your help.
If I get your question correctly then, from User defined functions, you could add a Matlab function block with the following code:
function fcn(in)
%#codegen
coder.extrinsic('acker', 'place')
# Now you can use acker, place so add more code.

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.

how can this function "resizeColumnscore" resizes image?

I want to know how can this function(from MATLAB) resize the columns of an input image using weights an indices previously computed.
Which equations uses to do that?
resizeColumnsCore(double(in), weights', indices');
When I looked for a function called resizeColumnsCore in MATLAB 7.11.0 (R2010b) I didn't find anything. However, I did find a MEX-file by that name in MATLAB 7.8.0 (R2009a) in this subdirectory of the Image Processing Toolbox:
C:\Program Files\MATLAB\R2009a\toolbox\images\images\private\
I guess they've phased it out or replaced it with another function in newer MATLAB versions. Now, if you want to know what the MEX-file does, you need to look at the source code it is compiled from. Luckily, it appears that this source code resizeColumnsCore.cpp can be found in the following directory:
C:\Program Files\MATLAB\R2009a\toolbox\images\images\private\src\misc\
And you can look through that code to determine the algorithms used to resize the columns of an image given a set of weights and indices.
Now, if you want to know how these input arguments to resizeColumnsCore are computed, you'll have to look at the code of a function that calls it. I know of at least one function in the IPT that calls this function: IMRESIZE. If you type edit imresize at the command prompt it will open that function in the Editor, allowing you to look through the code so you can see how the arguments to resizeColumnsCore are created.
What I can tell you for R2009a is that there is a subfunction in the file imresize.m called contributions which computes the weights and indices that are ultimately passed as arguments to resizeColumnsCore. That is where you will want to start looking to determine what algorithms are used to compute these arguments.
Looks like this isn't a proprietary MATLAB function. Could we see some code or a link to the code?