Using symbolic variables in Simulink - matlab

How do I use symbolic variables in the Simulink block diagram for different blocks? I'd like to run linmod2 and obtain a transfer function in the terms of the symbolic variables.

According to John D'Errico, aka woodchips, this likely not possible. That was my understanding of the way the linmod family of algorithms worked as well. However, what are you trying to do that you need to get the analytic representation of the model with the symbolic parameter? There may be other ways to accomplish what you need, please elaborate.

Related

Simbiology toolbox and fmincon in MATLAB

Is is possible to use the model simulated in the Simbiology toolbox of Matlab
to be used to implement fmincon for the same by calling the model from Simbiology?
It is possible to simulate the SimBiology model from a MATLAB script or the command line (see sbiosimulate). This allows the simulation results to be used by any other MATLAB function as needed. I assume that in your case you want to use the simulation results to construct an objective function to use with fmincon and it is possible. Let me know if you need more details.
The short answer is probably, yes. If you have access to the tools and try this, let me know and we can help further.

What is actually symbolic variable in matlab?

I am new in learning matlab. when I am using the solve() function, matlab warning me that i must use a symbolic variable before using the solve function. but I actually don't know what the sym variable is. or What is the difference between the symbolic variables and the ordinary variables of the base workspace?
Symbolic variables are useful to express equations and manipulate them in an analytic manner. You can use them to manipulte them algebrically, without the need of actually associating any type of numbers.
Suppose you want the exact analytical form of a solution for an equation, in terms of symbols that express this function. Then you can use a sym variable to express and operate with the unkwons, rather than to use on numerical methods to find solutions
Symbolic variables are also useful to operate with tranfer funcions and perform simplications that are very tedious If done without a computer program.
You also can associate numbers with sym variables, once you have done all the all the intended operations.
If you don't want perform operations with algebraic variables, you should checkout the fsolve function

MATLAB - How to set sigma in templateSVM

I have a dataset with multiple labeled vectors and I wanted to perform a multi-class SVM with RBF Kernel with the integrated function in MATLAB called 'templateSVM'.
To do so, I use the templateSVM function with the following command:
t = templateSVM('BoxConstraint', 1, 'KernelFunction', 'rbf')
The problem is that I cannot find how to set the 'sigma' parameter.
Thanks to previous computations, I know that C=1 and sigma=8 are the best parameters to get the best results. Not knowing how to set sigma leads me to awful results.
Would you know how to set this parameter?
Thanks a lot in advance.
Unfortunately the options available with templateSVM seem to be quite limited (I had this problem myself and couldn't find a solution). There are some crucial options (such as the RBF sigma parameter) that do not seem to be available with templateSVM but are available with svmtrain.
I know that this isn't a real answer to your question, but I suggest that you look into using libsvm instead - it is very configurable and integrates well with Matlab.
I know it's an old question, but the answer would be useful for new users.
Link below can answer the question:
https://www.mathworks.com/matlabcentral/answers/336748-support-vector-machine-parameters-matlab
"setting SIGMA": Use the 'KernelScale' name-value pair.

Patternsearch discrete variables

I want to optimize a multi-variable function with the patternsearch function in MATLAB. The function requires a lower and upper boundary and looks within the boundaries in a continuous domain.
I however have a discrete set of values in an excel file and would like the algorithm to search within this discrete domain instead of in the continuous domain.
Is this possible with patternsearch?
Maybe I don't understand correctly your question but if you have a (discret and finite) set of values, why don't you compute the function's value at these points and return the minium?
In short, no. That is not what patternsearch is intended for. Optimization techniques for discrete and continuous search spaces are quite expectedly different.
If you're looking for an approximate answer however, it is possible to use spline, polyfit, etc. to arrive at an approximate continuous function for your data and then apply patternsearch on it.
If you provide greater detail about your problem, I or someone else may be able to suggest a more suitable way of working with your data.
The best optimization tool for this is the Genetic Algorithm. This optimization tool comes with Matlab's global optimization toolbox and allows for optimization of both continuous and discrete variables at the same time.
In the genetic algorithm variables that are integers have to be declared as such. Non-declared variables are continuous by default.
Check the Global Optimization Toolbox guide for information on how it works: http://it.mathworks.com/help/pdf_doc/gads/gads_tb.pdf.

Generate equation from Simulink Model

I have a large simulink model with many source and sink blocks, many with only elementary arithmetic operations in between. I have been asked to document the equations behind the model. I am currently doing this manually and I am finding it rather slow and there is a relatively high chance of errors in the process.
Is there any way for Simulink to generate the equations (in MATLAB syntax for example) automatically?
There is no utility in MATLAB/Simulink that can do exactly what you are looking for (and I personally don't know of any third-party tools that can do this, either).
However, I think that your best bet might be to make use of Simulink Coder. This will allow you to convert your Simulink model to C code. From that code, you may be able to extract the equivalent equations more easily than you can by analyzing the Simulink model by hand.
The catch, though, is that Simulink Coder is an add-on package to base Simulink, so you may or may not have this tool available to you.