keeping equations in different formats
이전 댓글 표시
Hello All.
I have a problem. In my project I have three equations which in times I use with symbolic analysis and some times with numerical values. The problem is that I cannot keep the equations as syms due to the following reasons:
1. I need to always change update the syms in different parts of the code and functions 2. Using subs or eval commands take a lot of time mainly when I use loops to change the values.
Is there a way that I could have the equations saved and call them at symbolic form or numerical form and change the variables without using subs/eval?
Thanks!
Gil,
댓글 수: 8
José-Luis
2017년 8월 1일
How about encapsulating and using functions?
Gil Maor
2017년 8월 2일
Thanks for your reply!
I did not understand your suggestions, can you please elaborate?
Thanks!
José-Luis
2017년 8월 2일
Ok, but could you please provide an example of what you mean. I am having a hard time understanding exactly what you are trying to achieve.
Gil Maor
2017년 8월 2일
Hi,
lets say I have an equation D=A+B+2C=4
I want a way that I could call this equation as symbolic so I could drevive, for example diff(D,C)=....
and in another time I could just say that A=1 D=2 (without subs commnad) because the subs command works very slow and if I want to change values in a loop it take a lot of time ( 5 min..) since my original equation is very big.
At the moment I copy&paste of the equation when used to in a loop.
I hope I'm clear enough.
Gil,
Stephen23
2017년 8월 2일
"D=A+B+2C=4"
D=4
Gil Maor
2017년 8월 2일
Thanks Stephen
I did not understand how to place values in the variables
Gil,
Karan Gill
2017년 8월 2일
If you want to save/load equations, then use MAT files: https://www.mathworks.com/help/matlab/matlab_env/save-load-and-delete-workspace-variables.html
Of course, that won't work if your numeric values keep changing. You'll have to use subs. Can you provide an example where subs is too slow?
Gil maor
2017년 8월 3일
채택된 답변
추가 답변 (1개)
Walter Roberson
2017년 8월 3일
0 개 추천
I suggest that you could keep a struct, one field of which is the symbolic form, and another is the result of calling matlabFunction to transform the symbolic form to a function handle for numeric work.
카테고리
도움말 센터 및 File Exchange에서 Operations on Strings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!