I have a very complicated code that I can't make sense of on paper. Is there a good way to convert this to an equation I can actually see and can figure out what's going on in non-code format. Even when I spend the 15 minutes figuring out what the equation represents on paper, I can't be sure it is right due to the complexity (especially with parentheses). This has been a continuous problem so I would like a "teach a man to fish" solution rather than just giving me the equation.
(g/((beta*g*rho)/T)^(1/2) - (g^2*rho*(beta + 1))/(2*T*((beta*g*rho)/T)^(3/2)))/(2*((g*(beta + 1))/((g*rho*beta)/T)^(1/2))^(1/2))
I tried using the help page "Insert Equations into the Live Editor" but the first step is "Go to the Insert tab and click Equation":
https://www.mathworks.com/help/matlab/matlab_prog/insert-equations.html
On my matlab page there is no "insert" tab. I only have tabs for "editor" "publish" and "view." There is an "insert" option in the editor tab, but this is only used to insert fa section, function or fi... Is there a toolbox that I need to add to get the "insert" tab?
As you can probably tell, searching for "insert" tab in google or matlab answers only gives me solutions for inserting a tab...

댓글 수: 1

Cris LaPierre
Cris LaPierre 2018년 11월 14일
편집: Cris LaPierre 2018년 11월 14일
What version of MATLAB are you using? You must be on at least r2016a.
There is no need to install any toolboxes to have access.
'Insert Equation" started on the Live Editor ribbon and then moved to a separate "Insert" tab, so it will depend on your version where it is. Just look for a summation symbol in your toolstrip similar to what is in the top of the text edit box here in MATLAB Answers (Σ).
Here is the getting started video from r2016a in case that helps see where it might be.

댓글을 달려면 로그인하십시오.

 채택된 답변

Cris LaPierre
Cris LaPierre 2018년 11월 14일
편집: Cris LaPierre 2018년 11월 17일

3 개 추천

You can only insert equations into a live script. Follow these steps to convert a *.m to a *.mlx if necessary. Or under '+ New', select 'Live Script'. Note in this image there is not yet an Insert tab. Just Publish and View.
Equations can be entered in LaTeX or built manually, but there is no good way to take an equation written in code and have the equation interpreter display it nicely. However, if what you want is a good way to visualize the equation, live scripts are great at displaying symbolic equations.
Create symbolic variables then enter the equation and run the code.
syms beta g T rho
(g/((beta*g*rho)/T)^(1/2) - (g^2*rho*(beta + 1))/(2*T*((beta*g*rho)/T)^(3/2)))/(2*((g*(beta + 1))/((g*rho*beta)/T)^(1/2))^(1/2))
ans =
To see it in context of the entire MATLAB interface, I'm including a screen shot as well. Note that the 'Editor' tab now says 'Live Editor', and 'Publish' now says 'Insert'. This is in r2018b.
livescriptEqn.png

댓글 수: 2

Dylan Languth
Dylan Languth 2018년 11월 14일
I see, I didn't realize I had to go into a different script. That works just as well though, thanks for the answer!
Cris LaPierre
Cris LaPierre 2018년 11월 14일
If you haven't seen live scripts before, I'd recommend looking at the getting started video above. They can make code much more readable. Execution can be a little slower if you use the run button, but when called from the command window, live scripts are on par with *.m files.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Tasneem Anwar
Tasneem Anwar 2021년 1월 9일

0 개 추천

syms theta4
-(r3^2)+(r11^2)+((r4^2)*(cos(theta4))^2)+(2*r11*r4*cos(theta4)+r2^2*(cos(theta2)^2)-2*r2*r11*cos(theta2)-2*r2*r4*cos(theta2)*cos(theta4)+(r9^2)+2*r9*r4*sin(theta4)+(r4^2)*(sin(theta4)^2)+(r2^2)*(sin(theta2))^2-(2*r2*r9*sin(theta2))+(2*r2*r4*sin(theta2)*sin(theta4))

카테고리

도움말 센터File Exchange에서 Scripts에 대해 자세히 알아보기

질문:

2018년 11월 14일

답변:

2021년 1월 9일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by