필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Is there a tool for drawing diagrams that connect equations?

조회 수: 3 (최근 30일)
Marco Sandoval Belmar
Marco Sandoval Belmar 2020년 8월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi there,
I don't know how to ask this question, actually. But I have a bunch of equations and constants and are all connected somehow. Let's say the following code:
R=8.314;
n=0.412;
a=4;
m=2;
S=10;
rho=1;
F=m*a;
P=F/S;
V=m/rho;
T=(P*V)/(n*R);
Is there a way that Matlab (or maybe another language) returns you a diagram with the workflow, or something like that the figure?
Because I think any language needs to define each constant and equation in order, so I just want that order back

답변 (1개)

John D'Errico
John D'Errico 2020년 8월 1일
편집: John D'Errico 2020년 8월 1일
I don't think there is a tool in MATLAB that will take a set of equations in arbitrary order, and then create this diagram.
You could parse the equations yourself, then extracting a list of all variables, and which side of the equality they fall on. That would be sufficient to create a directed graph (not a pictorial graph) but a matrix that describes all connections between nodes, and the direction of flow for each expression. Then you would work with that graph to allow you to traverse the system. This would allow you to identify which relations must come first.
Would it work well? Probably not, as it will be difficult as hell to write when loops wre involved, recursions, etc. Building the elements of a vector in a loop might be a complicated thing to do, especially if there were function calls in there. Abither problem is what to do is the same variable name was used twice? (A sadly common thing to see, with novice programmers reusing variables multiple times, with totally different meanings in each case.)
Worse, since in MATLAB, I can define a variable name that is the same as a function name, you would need to do some pretty intelligent parsing. In some cases, the necessary parsing would be impossible to perform automatically. (I imagine I can probably come up with an example of code that would contain just such an ambiguity, that only the person who understands what the expressions mean can resolve.)
Honestly, I don't think you need the tool you want to see, as it would seem to be more of a crutch than an aid in the end. And it would not be very useful for anything complex. Far better for you to just understand the computations you need to do. Then no special tool is necessary. It is just the matter of learning to program, and a tool that allows you to not learn what you need to do will cost you more in the end than it helps.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by