Is there already any functions operates on latex equations mathematically in Emacs? - emacs

I have been thinking on editing latex equations mathematically in emacs:
Select current math term, shift it left and right, even across a "=" and changing signs. Terms are defined by "+" and "-" and other defined delimeters.
e.g. \alpha \bm{x} - 3\bm{y} = 10t, place cursor on "3" and call a function, the -3\bm{y} is selected. Call another function can change the equation to -3\bm{y}+\alpha\bm{x}=10t or \alpha \bm{x}=10t+3\bm{y}
Put coefficients into brackets, and even collect coefficients out.
e.g. With a function call can change 2(x+y) to (2x+2y).
Select current macro under cursor, copy the euqation from previous "=" or from a previous label.
The list goes on....
I have been using AUCTeX, CDLaTeX and RefTeX but up till now I do not know any functions already exists that can reach the effects above. So I want to ask if anyone knows an existing package in emacs can do these? If not, I am planning to elisp them myself

Related

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

MatLab latex title doesn't work for powers (^)

In MatLab (R2015a), I want to style the title of my plots using latex.
This is working fine for some functions, but not if there's a power in the equation.
The below code works, and shows a formatted title to the right, and an unformatted title to the left.
It shows the warning:
Warning: Error updating Text.
String must have valid interpreter syntax: y = x^2
syms x y
eq = y == x^2;
subplot(1,2,1)
ezplot(eq)
title(latex(eq),'interpreter','latex')
eq = y == x+2;
subplot(1,2,2)
ezplot(eq)
title(latex(eq),'interpreter','latex')
EDIT:
I just found out I can get it to work by appending $ on both sides. But it seems weird that I would have to do this.
So this works:
title(strcat('$',latex(eq),'$'),'interpreter','latex')
Solution
The problem can be solved easily by adding $-signs before and after the generated LaTeX-expression. So you can change your «title-lines» to:
title(['$',latex(eq),'$'],'interpreter','latex')
An alternative is to use strcat as proposed in your question.
Explanation
Since you basically answered the question yourself already, I'm going to explain why it happened. Hopefully after reading this, it's no longer 'weird' behaviour. If you choose to use the LaTeX-interpreter in Matlab, you really get a LaTeX-interpreter. This means that the provided string must be valid LaTeX-syntax.
Using ^ outside a math-environment is considered invalid syntax because it is a reserved character in LaTeX. Some interpreters automatically add the $ before and after in this case, but throw a warning at the same time.
The output of the latex-function in Matlab is provided without the $-signs. This way you can combine outputs and concatenate if needed without creating a mess with $-signs.
To change to the math-environment in LaTeX you can use the already mentioned shortcut $...$. An alternative way is to use \begin{math} your_equation \end{math}. It produces the same result for your equations and can be used here for demonstration purposes. The following line would do the same job, but is a bit longer to write:
title(['\begin{math}',latex(eq),'\end{math}'],'interpreter','latex')
Now, the reason why only one of your equations is displayed correctly, lies in the invalid character ^ in y = x^2. Matlab then chooses interpreter none and therefore displays the string unformatted. The +-sign in y = x + 2 is valid outside a math-environment, so it gets displayed correctly (but is not interpreted in a math-environment).

MATLAB: F1 help function in Editor refers to a wrong function

I am using MATLAB 2014b.
If I write a line like
A = regexp(strcat('some string'),expression);
Placing the cursor on the first function (here regexp) lets me get the content help of it by pressing F1.
If I now move the cursor to strcat I also get the content help of regexp. This is just an example; the same problem happens for every function.
In MATLAB 2012b, I get the correct behavior. How can I make MATLAB 2014b act the same way?
Note: If I highlight the function name and press F1, I'll get the right content help. But this is just a workaround.
I don't have MATLAB 2012b to test on right now and I'm running 2015a, but I feel it might be an issue with your test case. Try putting the cursor within the brackets that the function is called with. Let me know if it works in 2014b!
regexp help:
strcat help:

Matlab: how to manupulate expression

I am currently having an equation that contains 4~5 variables, and I am unfamiliar with matlab. I want to see how a variable change with the other variable fixed (might assign them some value). Maying graphing them out will help. I found it cumbersome to work in the main GUI in matlab, this is mainly after I type in my equation, I didn't know if the expression is what I want because of missing brackets, etc.
Recently I found mudpad, it is better because it will show you the expression in pretty form. I am wondering is there any other tool-box that is more suitable for my intention?
Update:
Ps=1;
Pr=1;
Pd=1;
g=0.25;
d1=1;
d2=1;
n=0.18;
Yr = #(x)(Ps)/(d1*((Pd*g^2)/d2 + (n*(x- 2))/(x- 1)));
Yr_=ezplot(Yr,0,1);
There is actually 4 more equations to plot and I am only posting one of them.

Matlab formula equation editor GUI

How i can execute an equation from GUI?
Example:
How i can do this with various type of equation?
Thanks the answers.
I'm not entirely sure what you mean, but I think you want to grab the equation that a user types in to a text box and turn it in to a function?
Why does your F change from 3 arguments to 4? i.e. F(x,y,y') --> F(1,0,5,-1) in the next line? (The examples of F you gave don't seem to match up with your equation..)
In any case, check out eval(), perhaps that is what you want.
It takes in a matlab command as a string, e.g. 2 + 3, and evalutes it.
So
eval('2+3') % gives 5
eval('f=#(x,y,ydash) y*sqrt(1+ydash^2)') % gives a function f
f(1,5,-2) % gives 11.1803
But in any case, how do you expect the user to type in the square root symbol and the squared symbol? The eval() approach relies on them typing in syntax that matlab will understand.
If you clarify your question a bit more this will be easier.